• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:checkbox Problem Struts

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic