2 Replies Latest reply on Mar 6, 2009 6:56 AM by Suruchi Sahni

    Using Map<String,List<String>> in <s:selectItems>

    Suruchi Sahni Newbie

      I need to display a city dropdown which will change on the basis of state dropdown. So I defined them in the bean(used as sM in .xhtml) as:

          List<String> states;
          Map<String,List<String>> cities;

      In .xhtml, for states dropdown I am using :

                                  <h:selectOneMenu id="state" value="#{tS.selectedState}" >
                                                              <a:support event="onchange"  reRender="city"></a:support>
                                                              <s:selectItems value="#{sM.states}" var="i" label="#{i}" />

      It is working fine and I get values being displayed in dropdown

      In same .xhtml, for cities dropdown I am using :

           <h:selectOneMenu id="city" value="#{tS.cityField}" rendered="#{tS.selectedState != null}" >
                                                               <s:selectItems value="#{sM.cities[tS.selectedState]}" var="i" label="#{i}" />

      Code in the bean annotated as tS in .xhtml is

          private String selectedState;
          private String cityField;
      //Getters and setters

      Now when I run the page, city dropdown does not get rendered at all, inspite of changing the value in state dropdown.I do not get any exception also.

      Please tell me why it is behaving so? If I print the value of selectedState , the value is printed and is changed on changing the state in dropdown.

      Please help.