2 Replies Latest reply on Aug 5, 2008 8:03 AM by Ilya Shaikovsky

    multiple selectOneMenus ->

    Ranil Wijeyratne Newbie

      hi, i have a problem since im generating form fields dynamically.

      i have a hashmap in a sessionbean: HashMap<String, List\<myObject\>>

      in the view i'm iterating through the hashkeys using <ui:repeat> and displaying the elements of the list in a selectbox. like this:

      <ui:repeat value="#{myHashMap.keySet}" var="key">
       <h:selectOneMenu id="selector" value="????" converter="#{myConverter}">
       <s:selectItems value="#{myHashMap.get(key)}" var="object" label="#{object.name}" />
       <a4j:support event="onchange" action="#{??bean.someaction??}" reRender="contentOfSelection" />
       </h:selectOneMenu>
       <h:panelGroup id="contentOfSelection">
       --- diplay content of selection ---
       </h:panelGroup>
      </ui:repeat>


      my question is now where and how to store the selected item, first i just thought i could have a single myObject property as selection, but of course that doesn't work since i'll have several selections.

      it would be perfect if i could have another hashmap as selection, kind of like HashMap<String, myObject>

      any ideas?

        • 1. Re: multiple selectOneMenus ->
          Ranil Wijeyratne Newbie

          ok, i managed to handle the selection. by using a new class as hashmap value containing the list and a selection

          HashMap<String, ListSelectorObject>
          
          ..........
          
          class ListSelectorObject {
           MyObject selection;
           List<MyObject> list;
          }


          but now i have a new problem: jsf lifecycle. remember i want to display the content of the selection under the selectbox, as soon as i select something new. so i add a4j:support to the selectonemenu.

          but now i have the problem, when i change the value, the form gets validatet (it contains some fields that have to be) , i could use immediate=true but then the model doesn't get updatet and the new values arent displayed.

          any ideas?

          • 2. Re: multiple selectOneMenus ->
            Ilya Shaikovsky Master

            add a4j:region around select and panelgroup