3 Replies Latest reply on Feb 26, 2009 10:44 AM by Waqas Arshad

    unable to reterive updated value

    Waqas Arshad Novice

      Still having a small problem. I need to update one list on the basis of other.

       <h:selectOneMenu value="#{Test.state}" id="abc">
       <f:selectItems value="#{Test.states}"/>
       <a4j:support event="onchange" reRender="cityList"/>
       <h:selectOneMenu value="#{Test.city}" id="cityList">
       <f:selectItems value="#{Test.cities}"/>
       <h:commandButton id="btn" value="Hello" action="#{Test.res}"/>

      public class Test {
       private String state;
       private List<SelectItem> states;
       private String city ;
       private List<SelectItem> cities;
       public List<SelectItem> getStates() {
       states = new ArrayList<SelectItem>();
       states.add(new SelectItem("<=== SELECT ===>"));
       states.add(new SelectItem("ABC"));
       return states;
       public List<SelectItem> getCities() {
       cities = new ArrayList<SelectItem>();
       cities.add(new SelectItem("<=== SELECT ===>"));
       if(this.getState() != null) {
       return cities;
       ...setter & getters
       public void res() {
       System.out.println("Button.........."+this.getState() +" "+this.getCity());
       }//end res
       public void getList() {
       cities.add(new SelectItem("123"));
       cities.add(new SelectItem("456"));
       }//end getList()
      }//end class

      Everthing works fine and city list updates properly but when i press button i only get state value and city value returns null.
      I've been having this problem for the last two weeks. So plz correct me where i m doing it wrong.