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

html:checkbox Problem Struts

Kash Mhai

Joined: Apr 01, 2005
Posts: 29
Hi guys,
Have started using Struts recently. I have a small problem with <html:checkbox />. In the JSp whether I check the box or not the value of the checkbox is appearing as "on" in the Action class. I haev a getter, setter method too for this control and am resetting the property to null also. But still I am getting the same prob. Can some help me in correcting my mistake?
The code -
<html:checkbox property="chkItem" value="Y" /> etc etc
<!-- Have tried removing the value attribute too, but of no use---->
-----Action form--------
private String strChkItem;
public String getChkItem()
return strChkItem;
public void setChkItem(String strTmp)
this.strChkItem = strTmp;
public void reset()
strChkItem = null;

THanks in advance,

-------------<br />There are wheels within wheels...<br />P.G Wodehouse
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

This was a fun one.

You need to change reset's method signature to:
public void reset(ActionMapping mapping, HttpServletRequest request)

The reset method is not getting called.

A good workman is known by his tools.
Kash Mhai

Joined: Apr 01, 2005
Posts: 29
I have used the <html:multibox /> as a workaround. This worked too. Involved a lil bit more code, but it worked.

Thanks for the solution. Will check it out. I am all smiles coz i feel this is gonna work.
Thanks a lot
I agree. Here's the link:
subject: html:checkbox Problem Struts
It's not a secret anymore!