You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex Shneyderman <al...@law.columbia.edu> on 2003/07/10 16:49:57 UTC

Simplest way to clear DynaActionForm?

What is the fastest/simplest way of clearing the DynaAcitonForm?

I am looking for something like:

DynaActionForm form = init here;

:
:

logic goe s here

if (need to manually clear the form) {
   form.clear (); // ????
}

Thanks,
Alex.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Simplest way to clear DynaActionForm?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 10 Jul 2003, Alex Shneyderman wrote:

> Date: Thu, 10 Jul 2003 14:36:04 -0400
> From: Alex Shneyderman <al...@law.columbia.edu>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
>      alex@law.columbia.edu
> To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
> Subject: RE: Simplest way to clear DynaActionForm?
>
> Thanks, that is exactly what I was looking for.
>
> So that Map is mutable?

Yes.

> Is there any reason not to have setMap ()?

Implementing that would mean you'd have to give up the type checking that
DynaActionForm gives you on the set() calls.  That doesn't sound like a
good thing to me.

For bulk loading and unloading of form bean properties, check out
PropertyUtils.copyProperties() and BeanUtils.copyProperties() -- both of
them know what to do with DynaActionForm beans, and the latter will even
do type conversions for you.

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Simplest way to clear DynaActionForm?

Posted by Alex Shneyderman <al...@law.columbia.edu>.
Thanks, that is exactly what I was looking for.

So that Map is mutable? Is there any reason not to have setMap ()?

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Thursday, July 10, 2003 2:28 PM
> To: Struts Users Mailing List; alex@law.columbia.edu
> Subject: Re: Simplest way to clear DynaActionForm?
> 
> 
> 
> On Thu, 10 Jul 2003, Alex Shneyderman wrote:
> 
> > Date: Thu, 10 Jul 2003 10:49:57 -0400
> > From: Alex Shneyderman <al...@law.columbia.edu>
> > Reply-To: Struts Users Mailing List
<st...@jakarta.apache.org>,
> >      alex@law.columbia.edu
> > To: struts-user@jakarta.apache.org
> > Subject: Simplest way to clear DynaActionForm?
> >
> > What is the fastest/simplest way of clearing the DynaAcitonForm?
> >
> > I am looking for something like:
> >
> > DynaActionForm form = init here;
> >
> > :
> > :
> >
> > logic goe s here
> >
> > if (need to manually clear the form) {
> >    form.clear (); // ????
> > }
> 
> One option would be to call the initialize() method, which sets all
the
> properties to their initial values as specified in the
struts-config.xml
> file.
> 
> Another choice would be to call form.getMap().clear() which will
remove
> all the entries from the internal map being used to maintain property
> values.
> 
> >
> > Thanks,
> > Alex.
> >
> 
> Craig
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Simplest way to clear DynaActionForm?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 10 Jul 2003, Alex Shneyderman wrote:

> Date: Thu, 10 Jul 2003 10:49:57 -0400
> From: Alex Shneyderman <al...@law.columbia.edu>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
>      alex@law.columbia.edu
> To: struts-user@jakarta.apache.org
> Subject: Simplest way to clear DynaActionForm?
>
> What is the fastest/simplest way of clearing the DynaAcitonForm?
>
> I am looking for something like:
>
> DynaActionForm form = init here;
>
> :
> :
>
> logic goe s here
>
> if (need to manually clear the form) {
>    form.clear (); // ????
> }

One option would be to call the initialize() method, which sets all the
properties to their initial values as specified in the struts-config.xml
file.

Another choice would be to call form.getMap().clear() which will remove
all the entries from the internal map being used to maintain property
values.

>
> Thanks,
> Alex.
>

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org