Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:checkbox Problem Struts

 
Kash Mhai
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Kash
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kash Mhai
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marc,
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
Kash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic