0

I am trying to implement Survey functionality in Struts application. For each survey questions, users select one options among Excellent, Very Good, Good, Satisfactory or Poor.

So, what I am trying to achieve is I need to have "unique name" for at each iteration of questionList so that user can select only one option per question.

Here is the part of jsp I have pasted:

<s:form id="screeningForm" action="submitSurvey" >
    <display:table uid="row" name="${questionList}"   >
        <display:column  property="statement" title="STATEMENT" />
        <display:column   title="EXCELLENT" >
            <s:radio name=?? list="{..}"></s:radio>
        </display:column>
        <display:column  title="VERY GOOD">
            <s:radio name=?? list="{..}"></s:radio>
        </display:column>
        <display:column  title="GOOD">
            <s:radio name=?? list="{..}"></s:radio>
        </display:column>
        <display:column   title="SATISFACTORY">
            <s:radio name=?? list="{..}"></s:radio>
        </display:column>
        <display:column  title="POOR">
            <s:radio name=?? list="{..}"></s:radio>
        </display:column>
    </display:table>

Thank you in advance!

MohanaRao SV
  • 1,117
  • 1
  • 8
  • 22
user1171699
  • 101
  • 13

2 Answers2

0

You will add the index or count to the name for unique. like this

<s:iterator status="status" value='{0, 1}'>
      Index: <s:property value="%{#status.index}" /> <br />
      Count: <s:property value="%{#status.count}" /> <br />  
   </s:iterator>

Refer this link.

Hope this may helpful for you

muthu
  • 5,381
  • 2
  • 33
  • 41
  • Thanks for the response muthu. This trick can be helpful on some other scenarios. I have pasted the solution below. – user1171699 Jan 04 '13 at 15:49
0

I solve this problem by adding a list at action class (private List select;) and gave name to each radio buttons as name="select[%{#attr.row_rowNum - 1}]"

<display:table uid="row" name="${questionList}"  requestURI=""  frame="" >
    <display:column  property="statement" title="STATEMENT" />
    <display:column   title="EXCELLENT" >
        <s:radio name="select[%{#attr.row_rowNum - 1}]" theme="simple" list="#{'1':''}"></s:radio>
    </display:column>
    <display:column  title="VERY GOOD">
        <s:radio name="select[%{#attr.row_rowNum - 1}]" theme="simple" list="#{'2':''}"></s:radio>
    </display:column>
    <display:column  title="GOOD">
        <s:radio name="select[%{#attr.row_rowNum - 1}]" theme="simple" list="#{'3':''}" ></s:radio>
    </display:column>
    <display:column   title="SATISFACTORY">
        <s:radio name="select[%{#attr.row_rowNum - 1}]"  theme="simple" list="#{'4':''}" ></s:radio>
    </display:column>
    <display:column  title="POOR">
        <s:radio name="select[%{#attr.row_rowNum - 1}]" theme="simple" list="#{'5':''}"></s:radio>
    </display:column>
</display:table>
lmcanavals
  • 2,339
  • 1
  • 24
  • 35
user1171699
  • 101
  • 13