views:

846

answers:

2

Hi at all... I have a complicated problem and I hope to explain it clearly possible...

I have 2 list. On my jsp I have a nested iteration with this 2 lists, inside this there is a tag.

This is the code:

<s:iterator value="listSurveyToRender" var="s" status="counterS">
                 <s:iterator value="listSurveyValuesToRender" var="sv" status="counterSv" >
                          <s:if  test="%{#s.idsurvey==#sv.survey.idsurvey}">
                             <td><s:radio list="sv"  listValue="valoreTesto" name="provaRadio1" />
                          </s:if>
                 </s:iterator>

This is the result of this jsp:

Question 1: (first iterator)
   resp 1:          (second iterator)
   resp 2:
   resp 3:
Question 2: (first iterator)
   resp 1:          (second iterator)     
   resp 2:

The problem is that, when I select the radio, because the list is unique for all, the selection exclude the others...

I need to restrict this exclusion on the second iterator.

Thanks!

+1  A: 

To the point: to separate radio button groups, you need to give them each a different name.

I don't do Struts, but in theory, replacing

name="provaRadio1"

by

name="provaRadio1${counterS.index}"

should do.

Reading/interpreting the generated HTML source (open page in browser, rightclick, view source) should also give a lot of new insights.

BalusC
I resolved with your help.. This is the solution that I find:<s:radio list="sv" listValue="#sv.valoreTesto" listKey="#sv.idsurveyValues" name="domandeCheckbox[%{#counterS.index}]" />domandeCheckbox is a List of strings that contain the listKey value.
Luigi 1982
A: 

It may be possible to do something like this:

  <s:set name="x" value="0"/>
<s:iterator value="listSurveyToRender" id="s" status="counterS">
             <s:set name="x" value="%{x + 1}"/>
             <s:iterator value="listSurveyValuesToRender" id="sv" status="counterSv" >
                      <s:if  test="%{#s.idsurvey==#sv.survey.idsurvey}">
                         <td><s:radio list="sv"  listValue="valoreTesto" name="provaRadio%{x}" />
                      </s:if>
             </s:iterator>
 </s:iterator>

I haven't had a chance to test this but basically every outer iteration will increment x and x will be used to create a unique id for the radio button of each group.

In your action you will have to declare provaRadio1, provaRadio2 etc to get the value submitted.

Vincent Ramdhanie