On Mon, 8 Jul 2002 [EMAIL PROTECTED] wrote:

> Date: Mon, 8 Jul 2002 16:06:26 -0400
> From: [EMAIL PROTECTED]
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: DynaActionForm Advantages
>
>
>
> > The benefit of using DynaActionForm instead is in one of the following
> two
> > use cases:
> >
> > * If your ActionForm bean doesn't have a custom reset() or validate()
> >   method, you don't need to write your own form bean class at all -
> >   simply configure the properties in struts-config.xml.
> >
> > * If your ActionForm bean does have a custom reset() or validate()
>   method,
> >   those are the only ones you have to write -- no more time wasted with
> >   all the property getter and setter methods (have you ever done anything
>   more
> >   boring that writing those?).  Simply subclass DynaActionForm and
> >   implement the validate() method in the usual way (although it will
> >   have to use get() to get the values to be tested, instead of the
> >   usual property getter methods).
> >
> > Given how many situations are covered by one or the other of the above,
> > I'd say DynaActionForm is modestly useful :-).  But, like most things,
> > it's just an option.
> >
> > Craig
> >
>
> So why would anyone ever NOT use DynaBeans?
>

Possible reasons why not:

* You're currently still stuck with Struts 1.0.2 :-).

* Non-trivial getter and setter implementations that do more than just
  manipulate an instance variable.

* Required code in the no-args constructor (although in most cases you can
  get around this by doing initialization in the reset() method instead.

An additional reason to consider them was added in a recent nightly build
-- you can now conveniently initialize arrays of constants in your
struts-config.xml file, which is very convenient for setting up standard
options for an <html:select>, or the default set of values for an
<html:multibox>.  Example:

  <form-bean name="foo" type="org.apache.struts.action.DynaActionForm">
    ...
    <form-property name="optionsList" type="java.lang.String[]"
     initial="{ 'First option', 'Second option', 'Third option' }"/>
    ...
  </form-bean>

The syntax for initializing an array is basically like what you'd use to
initialize them in a variable declaration, except you can only use
constants.

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to