Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts checkbox problem.

 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP page with a checkbox DO. Code is:

<logic:equal name="dynaActionForm" property="chkDO" value="0">
<td height="22"><input type="checkbox" value="0" name ="chkDayOptional" checked/></td>
</logic:equal>
<logic:equal name="dynaActionForm" property="chkDO" value="1">
<td height="22"><input type="checkbox" value="1" name ="chkDayOptional" /></td>
</logic:equal>

If a value of 0 is returned from database then the checkbox shold be checked and if 1 then not. Please suggest me how do i design this? Should i make both of them rendered on the page? I have to send the value 0 or 1 based on the selected or not when the page submitted.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need the logic:equals tags. Just specify initial="0" when you define the chkDO property in the struts-config.xml file. Then just use the <html:checkbox> tag in your JSP. Example:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic