0 Replies Latest reply on Jan 13, 2013 10:14 PM by Prasanna Subramanian

    h:selectOneMenu holds the previous state

    Prasanna Subramanian Newbie

      Hi Friends,

                     I had problem in <h:selectonemenu> ,

      steps to arise,

      1.Deploy webapplication


      2.In jsp page ,


      <h:form id="sampleFormId" binding="#{Sample.initForm}">

      <a4j:outputpanel id="countryOutPutPanelId">

      <h:panelGrid columns="2">

      <h:outputText value="Country:"/>

      <h:selectOneMenu value="#{Sample.country}" 



              <f:selectItems value="#{Sample.countryItemList}"/>

               <a4j:support action="#{Sample.countryComboBoxAction}"








      3.In Sample.java


      private SelectItem countrySelectItem;

      private HtmlForm initForm;//(Getter setter applicable)

      private String country;//(Getter setter applicable)

      private List<SelectItem> countryItemList = new ArrayList<SelectItem>();//(Getter setter applicable)


      private void addingCountryItemList()


           countryItemList.add(new SelectItem("India"));

             countryItemList.add(new SelectItem("Malaysia"));

             countryItemList.add(new SelectItem("China"));




           *  countryComboBoxAction when change the selectitems


      public String countryComboBoxAction()







           * @return the initForm


          public HtmlForm getInitForm()


                countrySelectItem = -------------Select Country---------------------;








                //We need to display as its first so

                country = countrySelectItem.getValue.toString();


                   return initForm;




           * @param initForm the initForm to set


          public void setInitForm(HtmlForm initForm)


              this.initForm = initForm;




      4. when country changed from label countrySelectItem to india/Malaysia/China

           it will removed the countrySelectItem

           keep the state in India


      5.pause the action and redeploy the same war in tomcat


          the problem is when redeploy the war , the country must be added and selected  the countrySelectItem as want to shown ,But it holds lastly u selected india in jsp


      Expected: --------SelectCountry-----------------

      But it hold : India

      in jsp page


      can u help me?