struts2: problem in assigning a variable value to checkbox
- by vivmal
Hi All,
I am working on struts2. In my jsp page I want to assign the value of a string variable to a checkbox (when it is checked by user). I tried it many times like -
<% String code = "decompose"; %>
1)
<tr><td>
<s:checkbox name="codeCkBox" fieldValue="%{‘code’}" onclick="submit()"/>
</td></tr>
2)
<tr><td>
<s:checkbox name="codeCkBox" value="%{‘code’}" onclick="submit()"/>
</td></tr>
3)
<tr><td>
<s:set name="setCkBoxValue" value="%{‘code’}"/>
<s:checkbox name="codeCkBox" fieldValue="# setCkBoxValue" onclick="submit()"/>
</td></tr>
But everytime when I tried to get this value by checkbox name it returns variable name i.e “code”.
Looking for a solution.
Thanks in advance.