aspose file tools*
The moose likes Struts and the fly likes Struts2 checkbox value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 checkbox value" Watch "Struts2 checkbox value" New topic
Author

Struts2 checkbox value

rohant paralikar
Greenhorn

Joined: Jun 18, 2008
Posts: 4
Hi All,
i am using struts2 and jsp for UI.
I have 3 checkboxes on one of my page,and want to set the bean varible coresponding to these checkboxes on page submit
what i am doin is

<s:checkbox name="abcVO.field1" fieldValue="abcVO.field1" theme="simple" value="abcVO.field1" />

where abcVO is a action classes'(bean's )member which is an value object (a object class )
containing different fields like field1 ,field2.... this field is a character field and values it can take are '1' and '0'
now the problem is i want to set value to 1 if the checkbox is checked else to 0
but it its not getting set in my bean class
,null is what i am getting
my question is what value is set (true/1/or something else) on checking of checkbox element
how to achieve what i am supposed to?

Thanks In advance
-Rohant
rohant paralikar
Greenhorn

Joined: Jun 18, 2008
Posts: 4
I could send the value as 1 when the checkbox is selected by using the fieldValue attribute as fieldValue="1" but one problem still remains that is, when the checkbox is not checked then the value that gets set in bean/action class is null.Can I set it to 0, if not checked, just like fieldValue="1", when it is checked?
If anyone have an idea, please respond to the query

Thanks
-Rohant
[ June 21, 2008: Message edited by: rohant paralikar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 checkbox value