2 Replies Latest reply on Mar 19, 2010 9:10 PM by xlugo

    Simple Form

      I have this code:

       

       

      <h:form>


         <a4j:region id="region1">     
              <h:selectOneMenu value="#{myBean.selectedCountry}" id="countries" >
                  <f:selectItems value="#{myBean.listCountries}" />
                  <a4j:support actionListener="#{myBean.countryChanged}" event="onchange" reRender="states" />
                  <h:outputLabel value="Countries:" for="countries"/>       
              </h:selectOneMenu>
         </a4j:region>   
            
         <a4j:region id="region2">
              <h:selectManyListbox id="states" value="#{myBean.selectedListStates}">
                  <f:selectItems value="#{myBean.listStates}"/>
                  <h:outputLabel value="States:" for="states"/>
              </h:selectManyListbox>            
         </a4j:region>

       

      <a4j:commandButton actionListener="#{myBean.showValues}" reRender="country" value="execute" >
          </a4j:commandButton>

       

      <a4j:region id="region3">                      
              <h:outputText value="#{myBean.selectedCountry2}" id="country"/>
      </a4j:region>

       

      I want to read the selectedCountry value (and selectedListStates)

       

      my bean:

       

         // private selectedCountry, selectedCountry2

         //get and set methods ...

       

          public void showValues(ActionEvent event){

              this.selectedCountry2 = this.selectedCountry;       
             
          }

       

       

      If I just select  a item from selectOneMenu I get the correct value; but when I select a item from selectManyListBox I get a blank value.

       

       

      <managed-bean>
        <managed-bean-name>myBean</managed-bean-name>
        <managed-bean-class>package.MyBean</managed-bean-class>

        <managed-bean-scope>request</managed-bean-scope> <!-- I need to use request scope and not session scope --> 
      </managed-bean>