Link to home
Start Free TrialLog in
Avatar of germess
germess

asked on

Struts indexed checkbox problem

Hi Experts,
I am using struts checkbox with indexed=true and also I am trying to pass the current index into the checkbox's onclick function.  However, my JSP does not compile because it can't recognize the index
Could you help me with that?

<logic:iterate id="stepVO" name="manageStepForm" property="stepList" indexId="rowNum">  

  <td align="center" class="CUIFData">      
<html:checkbox name="stepVO" property="rmisFlag" indexed="true" value="<%= valRmis%>" onclick="setChangedStatus(<bean:write name="rowNum" scope="page"/>)"/>            
                              
 </td>

  </logic:iterate>
Avatar of boonleng
boonleng
Flag of Malaysia image

You can't put a <bean:write> tag inside the <html:checkbox> tag.
Try the following:

<logic:iterate id="stepVO" name="manageStepForm" property="stepList" indexId="rowNum">  

<td align="center" class="CUIFData">    
<html:checkbox name="stepVO" property="rmisFlag" indexed="true" value="<%= valRmis%>" onclick="setChangedStatus(<%=rowNum.toString()%>)"/>          
                         
</td>

</logic:iterate>

Regards,
Boon Leng
You can't put a <bean:write> tag inside the <html:checkbox> tag.
Try the following:

<logic:iterate id="stepVO" name="manageStepForm" property="stepList" indexId="rowNum">  

<td align="center" class="CUIFData">    
<html:checkbox name="stepVO" property="rmisFlag" indexed="true" value="<%= valRmis%>" onclick="setChangedStatus(<%=rowNum.toString()%>)"/>          
                         
</td>

</logic:iterate>

Regards,
Boon Leng
Avatar of germess
germess

ASKER

Boon Leng,
thanks for your response.
Unfortunately, the suggestion did not work. My page compiles with this line, but onclick="setChangedStatus(<%=rowNum.toString()%>)" does not get translated.
If I look at the Source of the page the value that gets passed into this function looks like : setChangedStatus(<%=rowNum.toString()%>)
Any suggestions?
thanks for your help!!!
ASKER CERTIFIED SOLUTION
Avatar of boonleng
boonleng
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of germess

ASKER

thanks!
let me try ...
Avatar of germess

ASKER

Boonleng,
thanks for your help!
Worked great, except I had to define the variable first like this:
<%
String onclick= "setChangedStatus(" + rowNum.toString() + ")";
%>
<html:checkbox name="stepVO" property="rmisFlag" indexed="true" value="<%= valRmis%>" onclick="<%=onclick%>"/>
Thanks for your help!