1 Reply Latest reply on Jan 7, 2012 7:49 AM by Cristian Mastrantono

    a4j:ajax re-instantiates a Bean Scope Viewed (jsf2)

    Cristian Mastrantono Newbie

      Hi there, I'm facing a weird problem (at least for me)...

       

      I have a bean with scope = view, and some code in the constructor of it. Then a xhtml has a h:selectOneMenu that with a a4j:ajax for updating the value selected on that component.

       

      The problem is, the first time I change the value of the combo, te bean is re-instantiated. The constructor is called again, and the valueChangeListener for the selectOneMenu isn't invoked. After that, everything seems to works fine. Every time I change the value of the combo, the valueChangeListener is invoked succesfully.

       

      There is my xhtml code

       

       

      <h:form>
      <a4j:outputPanel id="a4jFilter1" layout="block" >
           <h:selectOneMenu id="sortResultados" valueChangeListener="#{Search.changeSort}"  value="#{Search.sortResultsKey}">
                <f:selectItem itemLabel="Precio: Mayor a Menor"  itemValue="D" />
                <f:selectItem itemLabel="Precio: Menor a Mayor"  itemValue="A"/>
                <a4j:ajax event="valueChange" render="a4jFilter2" execute="@this" />
           </h:selectOneMenu>
           <label>Order by</label>
      </a4j:outputPanel>
      <a4j:outputPanel id="a4jFilter2" layout="block" >
                some code here...
      
      </a4j:outputPanel>
      
      </h:form>
      
      

       

      Am I doing something wrong?

       

      I'm using Netbeans 6.9.1 with the "bundled" JSF framework that comes with it... and glassfish for the server.

       

      Best regards,

      Cristian.