File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts checkbox problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts checkbox problem." Watch "Struts checkbox problem." New topic

Struts checkbox problem.

sachin yadav
Ranch Hand

Joined: Nov 24, 2005
Posts: 156
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 name="dynaActionForm" property="chkDO" value="1">
<td height="22"><input type="checkbox" value="1" name ="chkDayOptional" /></td>

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

Joined: Feb 15, 2005
Posts: 4864
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:

Consultant, Sima Solutions
I agree. Here's the link:
subject: Struts checkbox problem.
It's not a secret anymore!