You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Degoutin Jean-Philippe <je...@devoteam.com> on 2009/03/06 11:51:15 UTC

How to manage s:radio or s:select in s:iterator (Struts2)

My problem is as follow :

I iterate over a map of objects and theses objects contains a property that I want to expose in a s:radio.

Like this : I got a map "myMap" with 2 properties :
                - P1, the unique identifier of the object (P1 is also the key value of the  map)
                - P2 the property I want to expose as a s:radio (I also expose it a 2nd time as a s:textfield)


      <s:iterator value="myMap" >

            <s:textfield value="%{value.P1}" name=" myMap['%{key}'].P1"/>

            <s:radio list="#{'1':'1','2':'2','3':'3'}"

                  value="myMap['%{key}'].P2"

                  name="myMap['%{key}'].P2"

                  id="%{value.P1}"

            />

            <s:textfield value="%{value.P2}" name="myMap['%{key}'].P2"/>

      </s:iterator>

My map is initialized with several objects and properties of objects are also initialized.
 Result : When I display, I see P1 and P2 in the textfield but nothing is checked in radio buttons.
                When I submit, I can retrieve datas in texfields but not those in s:radio.

And it's exactly the same when I replace the s:radio by a s:select.

Thanks,
JPhilippe