> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 01, 2002 6:25 PM
> To: Struts Developers List
> Subject: Re: dynaforms & checkboxes
> On Fri, 1 Feb 2002, Andre Beskrowni wrote:
>
> > Date: Fri, 1 Feb 2002 17:23:35 -0500
> > From: Andre Beskrowni <[EMAIL PROTECTED]>
> >
> > 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".
> >
> > is this a case where RequestUtils.populate() needs a
> special case for
> > setting null Boolean values to "false",
>
> This is what the ActionForm.reset() method is for.
>
> You cannot really do it in the populate() method -- how do
> you decide that
> *every* boolean property in the underlying bean should be
> reset? It would
> also be a horrendous breach of backwards compatibility to
> change something
> like this now.
>
what do you think of adding an additional property to FormPropertyConfig
that would handle the default setting of null values? (note that this is
different from the "initial"). i'm thinking of something equivalent to the
SQL function NVL(x,y), which returns x if x is not null, and y otherwise.
this way, for form elements that don't always submit a value (checkboxes,
for instance), you can indicate that the absence of a this value should be
ignored, or that it means that the form property should get set to the
specified value.
i realize i can subclass FormPropertyConfig and use <set-property> to
accomplish this, but this does seem like something that might benefit the
greater good.
ab
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>