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

setting checkbox value

 
Whitney Albrecht
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srinivas Rao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will expect Boolean object rather than boolean value.

use set("name", Boolean.valueOf(false)) rather than using set("name", false).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic