wood burning stoves 2.0*
The moose likes Struts and the fly likes setting checkbox value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "setting checkbox value" Watch "setting checkbox value" New topic
Author

setting checkbox value

Whitney Albrecht
Greenhorn

Joined: May 09, 2005
Posts: 19
In my struts-config.xml I have:

<form-bean
name="aForm"
type="anActionForm">
<form-property name="chkbox1" type="java.lang.Boolean"/>
</form-bean>

anActionForm.java extends DynaValidator form. And in the reset( ) method I am trying to set the checkbox value to false by the following:
set("chkbox1", false);

However when I compile I get the following error:
"Cannot resolve symbol: method set(java.lang.String, boolean);"

Can anyone see why the set method (inherited from the struts ActionForm class) will not accept a boolean value?

Thanks
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
it simply won't since the set/get doesn't do type coercion. you'll need to have the checkbox values set to a string ('Y' for example), then convert that to a boolean primitive.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Srinivas Rao
Greenhorn

Joined: Aug 05, 2004
Posts: 14
It will expect Boolean object rather than boolean value.

use set("name", Boolean.valueOf(false)) rather than using set("name", false).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting checkbox value
 
Similar Threads
Radio button
Still not working - DynaValidatorActionForm and checkboxes
check box with html:checkbox
struts2 - spring - freemarker - message property key not working for validation
Checking Checkbox values in indexed form