2 Replies Latest reply on Feb 16, 2010 8:04 PM by xlugo

    Simple Form

      Hi, I use Richfaces 3.1.3 anf Myfaces 1.1.4

       

      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> 

       

      this code is ok.

       

      ---------------------------------------------------------------------------------------------------------------------------------------

       

      Then, I need to use the selected values (like parameters) in a method to show a table, but i dont know how to do it.

      I need a action button.

       

          <a4j:region id="region3">   

             <a4j:commandButton actionListener="#{myBean.showTableCountryStates}" reRender="table" value="show country" >
             </a4j:commandButton>                  
          </a4j:region>

       

       

      ......................

       

       

      myBean:

       

      public void showTableCountryStates(ActionEvent event){

               //read   selectedCountry
               String paramCountry = this.selectedCountry;

               This code no working

       

              //logic to the table

        • 1. Re: Simple Form
          ilya_shaikovsky

          you should remvoe region around the button - it's limits processing to just button.

           

          And b.t.w if you even stucked with 3.1.x because of environment requirements - it's highly recommended to use 3.1.6 which is the latest and more stable version.

          1 of 1 people found this helpful
          • 2. Re: Simple Form

            Let me try it, thank you very much-

             

            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>
            </managed-bean>