icefaces 1.8.2: update a table with many selectOnemenu depending on a selectOnemenu

51 views Asked by At

I have a ice:selectOneMenu with a list of cars. I need that, when I select a car, an optionals table with many selectOneMenu is updated and default values are automatically selected.

So:

Cars: <select>

Optionals Table
-----------------------
Colors: <select>
Engines: <select>
Seats: <select>
Interior Color: <select>
...
...

The problem is thatI change the Cars value but the table is not updated and its values are not selected

So I want that:

  • if I select a Ferrari car, in the optionals table: the red color is automatically selected, the 3902CC engine is automatically selected, etc.

  • if I select a Porche car, the white color is automatically selected, the 616/16 engine is automatically selected,etc.

I'm using icefaces 1.8.2 and probably I can not use an ajax tag.

How can I do?

Thanks!!

1

There are 1 answers

0
Yoda On

I've found a workaround solution. Using:

JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(),javascriptCodeString);

to add Javascript code to the page.

The string javascriptCodeString must contain a Javascript code that use CSS classes to bind a click event to an hidden <ice:commandButton styleClass="updateFieldsCommandButton" ... > that will call an action (for updating fields values):

function updateFields() {
  document.getElementsByClassName('updateFieldsCommandButton')[0].click();
}
var listOfFields=document.getElementsByClassName('fieldToBeUpdated');
for(var i=0,len=listOfFields.length;i<len;i++) {
   listOfFields[i].addEventListener('change', updateFields);
}

This works with icefaces 1.8.2 without needing an ajax tag.