tags:

views:

1101

answers:

1

Hi there,

I have multiple drop down menus with my JSF/ICEFaces application that update each others so depending on the selection of one the contents of others update.

The problem is that the menu is sending the wrong value. It seems it sends the value before instead of the current one! not sure why!

Any ideas?

Thanks,

Tam

  <td>
    <ice:selectOneMenu id="selectCurApplNm"
      value="#{statsDisplayAndFilter.applIDFilterPhrase}"
      disabled="#{statsDisplayAndFilter.disableCurrentApplIdNamesMenu}"
      valueChangeListener="#{statsDisplayAndFilter.fetchEventNames}"
      partialSubmit="true" immediate="true">
      <f:selectItem itemValue="" itemLabel="" />
      <f:selectItem itemValue="all" itemLabel="all" />
      <f:selectItems id="selectCurApplNmItems"
        value="#{statsDisplayAndFilter.currentApplIdItems}" />
    </ice:selectOneMenu>
  </td>
</tr>
<tr>
  <td>
    <ice:outputLabel for="SlctCompTyp" value="Event Name: " />
  </td>
  <td>
    <ice:selectOneMenu id="SlctCompTyp"
      value="#{statsDisplayAndFilter.eventNameFilterPhrase}"
      disabled="#{statsDisplayAndFilter.disableEventNamesMenu}"
      valueChangeListener="#{statsDisplayAndFilter.fetchMethodNames}"
      partialSubmit="true" immediate="true">
      <f:selectItem itemValue="" itemLabel="" />
      <f:selectItem itemValue="all" itemLabel="all" />
      <f:selectItems id="SlctcompTypeItms"
        value="#{statsDisplayAndFilter.eventNameItems}" />
    </ice:selectOneMenu>
  </td>
</tr>
+1  A: 

I found out that by the time it calls the method defined in valueChangeListener the value is not yet binded to the proper variable so I had to use the event variable to get the new value:

public void fetchEventNames(ValueChangeEvent e) throws SQLException{
   String filteringOptions = ""; 
   String newSelectedValue = e.getNewValue().toString();
       .....

And this solved the problem

Tam
The reason for that is the "immediate" keyword. This skips some phases of the JSF lifecycle and fires the Event *before* values get written back from UI to the model.
Gerhard Dinhof