struts dialog box not taking jsp scriplet

156 views Asked by At

I am using struts dialog box in a jsp page. I want that id of each dialog box should be dynamic. For that I am doing this code -

<%
    int counter = 0;
%>
<s:iterator var="RP" value="campaignList" status="currRow">
    <%
        counter++;
    %>
    <sj:dialog id="DivQuestionAnswer<%=counter%>" autoOpen="false"
        modal="true" width="750" cssStyle="font-size: 15px;"
        title="Question Results">
        <s:form name="frmUploadQuestion" id="frmUploadQuestion"
            action="uploadQuestion" method="post" theme="simple">
            <s:hidden value="" name="question.campaignId" id="campaignId" />
            <table width="100%" border="0" cellspacing="10"
                cellpadding="0">
                <tr>
                    <td width="45%">Question File :</td>
                    <td></td>
                    <td width="55%"><input type="file"
                        name="question.questionFile" id="questionFile" /></td>
                </tr>
            </table>
        </s:form>

    </sj:dialog>
</s:iterator>

But it is always taking id as DivQuestionAnswer<%=counter%>. Not like DivQuestionAnswer1,DivQuestionAnswer2,DivQuestionAnswer3.

2

There are 2 answers

0
Andrea Ligios On BEST ANSWER

You can't mix Scriptlets (<% %> , that you shouldn't use at all) with Struts tags (or Struts2-jQuery tags).

Also you don't need to: with an Iterator, you get an IteratorStatus object, that can be used as a counter:

<s:iterator value="campaignList" status="currRow">
    <sj:dialog id="DivQuestionAnswer%{#currRow.count}" ... >

Note: #currRow.count is 1-based, #currRow.index is 0-based.

0
Lijo On

`" You have put the counter inside double quotes so it will not work .

"\"" + <%=counter%>+ "\""