2 Replies Latest reply on Jul 31, 2007 1:38 PM by igx89

    Changing selected item in a selectOneMenu using AJAX?

      Say I have a selectOneMenu tag as follows:

      <h:selectOneMenu value="#{Bean.property1}">
      <f:selectItems value="#{Bean.list1}" />
      </h:selectOneMenu>

      If I re-render it using AJAX, the getter for Bean.property1 is never called (though the getter for Bean.list1 is!) and thus I can't change its selected value. Anyone know why that is?

        • 1. Re: Changing selected item in a selectOneMenu using AJAX?

          Because JSF works exactly like that according to the JSF spec.

          Spec says that a JSF component renderer is responsible for using the submitted value rather than the value from the model when the same view is rendered again (that is always true for Ajax responses).

          The general solution is DO NOT process the submitted value.
          You did not send the snippet with Ajax component. Post it and we will find the way.

          • 2. Re: Changing selected item in a selectOneMenu using AJAX?

            So components update the field bound to their value attribute on an AJAX request, but don't read that field after calling the action method and before performing the render? They just assume the bean never changes it? Why doesn't form submit processing (non-AJAX) not suffer from that issue then?

            I took that code from the a4j-dropDownBoxes demo at http://labs.jboss.com/jbossajax4jsf/demo/index.html. To get an idea of what I'm trying to do, add the following line to the end of the else clause in the changeOptions method in Bean.java:

            property2 = "500";

            Thanks!