Try using a Boolean value, something like this:
private Boolean myBoolean = null;
public boolean getMyBoolean() {
if( myBoolean==null ) return true;
return myBoolean.booleanValue();
}
public void setMyBoolean(boolean value) {
myBoolean = new Boolean(value); // or myBoolean= (value ?
Boolean.TRUE : Boolean.FALSE);
}
public void reset() {
myBoolean = null;
}
This has the desired behaviour of returning true if the value isn't set,
and returning the set value otherwise.
Bill Wallace
(585) 214-8872
Fax: (585) 295-4718
Element K
'the knowledge catalyst'
www.elementk.com
Gerard Weatherby
<gerard@charlesconsu To: "Struts Developers List"
<[EMAIL PROTECTED]>
lting.com> cc:
02/01/2002 11:06 PM Subject: Re: dynaforms &
checkboxes
Please respond to
"Struts Developers
List"
At 05:23 PM 2/1/02 -0500, you wrote:
>i've been testing the dynaform stuff and i'm trying to use a checkbox
>element in my form with a default value of "true". (just for the sake of
>reference, the form property is called "booleanValue".) however, if i
>uncheck the checkbox and submit, the dynaform is always set to "true".
i'm
>not sure if there's a workaround for this or not. i think the issue is
that
>when you submit an unchecked checkbox, no request parameter is sent for
it.
>so rather than sending booleanValue="false",
>request.getParameter("booleanValue")=null. as a result, when
>processPopulate() in RequestProcessor calls RequestUtils.populate(), the
>HttpRequest has no value for booleanValue and (i guess) just leaves it
with
>its initialized value of "true".
I'm still figuring all this out, but isn't this situation the type of
reason the execute method on Action
receives the original HtttpServletRequest?
if (request.getParameter("booleanValue")==null) {
myBean.setXxx(false);
}
Gerard Weatherby Voice: 860-365-0876
Charles Consulting, LLC Fax : 561-258-0876
http://www.charlesconsulting.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]
>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>