File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "setting checkbox value" Watch "setting checkbox value" New topic

setting checkbox value

Whitney Albrecht

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

<form-property name="chkbox1" type="java.lang.Boolean"/>
</form-bean> 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?

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="" target="_blank" rel="nofollow"></a>
Srinivas Rao

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:
subject: setting checkbox value
It's not a secret anymore!