As to "whether this is the right thing to do", I would say yes, IMHO. 
I understand why you may not like it, though.  For the customization
you want, you can override the RequestProcessor (or implement your own
ComposableRequestProcessor commands if you're using 1.3) and change
how validation is performed.

Hubert

On Fri, 18 Mar 2005 18:20:56 +0000, Lawrie Gallardo
<[EMAIL PROTECTED]> wrote:
> Sorry Hubert, I think you misunderstood me... I realise that in the current
> design of Struts the Action class execute() method is only called by the
> ActionServlet after the ActionServlet has invoked the validate method of the
> ActionForm (which in the case of ValidatingActionForm baseclass invokes the
> Validator plug-in validation method). My question was whether this was the
> right thing to do, or whether Struts could be implemented so that
> ActioonServlet invoked the Validator plug-in validation from an Action
> baseclass's validate method() instead, with ActionForms being reduced to
> just dumb data holders.
> 
> The reasons why I wondered if this design was feasible / preferable are
> detailed in my original post.
> 
> Lawrie
> 
> >From: Hubert Rabago <[EMAIL PROTECTED]>
> >Reply-To: Hubert Rabago <[EMAIL PROTECTED]>
> >To: Struts Users Mailing List <user@struts.apache.org>
> >Subject: Re: Wouldn't validation be better performed by Actions rather than
> >ActionForms?
> >Date: Fri, 18 Mar 2005 11:55:24 -0600
> >
> >It allows you to handle simple validations outside of the Action
> >class, which would only be called when there's data that can be passed
> >to the business tier (which may, among other things, perform business
> >validation).  Also, as the Validator plugin shows, it enabled
> >declarative validation.  So now, we don't even have to write
> >validation code in our action forms.  By the time execution reaches
> >the Action object, it can go straight to conversion without having to
> >worry about ParseException or NumberFormatException.
> >
> >Hubert
> >
> >On Fri, 18 Mar 2005 17:47:14 +0000, Lawrie Gallardo
> ><[EMAIL PROTECTED]> wrote:
> > > I appreciate that there are different levels of validation - I just
> >can't
> > > see why any of them are better handled by ActionForm (which could
> >otherwise
> > > just be a dum strut object/ map / etc) than by Action. Surely it is
> >better
> > > to keep all your presentation tier validation together in one place
> >where
> > > possible (although obviously you want to keep your business logic
> >validation
> > > with your business objects)?
> > >
> > > Lawrie
> > >
> > > >From: Hubert Rabago <[EMAIL PROTECTED]>
> > > >Reply-To: Hubert Rabago <[EMAIL PROTECTED]>
> > > >To: Struts Users Mailing List <user@struts.apache.org>
> > > >Subject: Re: Wouldn't validation be better performed by Actions rather
> >than
> > > >ActionForms?
> > > >Date: Fri, 18 Mar 2005 11:27:11 -0600
> > > >
> > > >You raise a lot of points, and I admit I won't be able to respond to
> > > >all of them in one email (due mostly to time constraints).  Besides,
> > > >there are others who could respond, so I'll leave some out for them.
> > > >:)
> > > >
> > > >There are/can be different levels of validation.  Some validation you
> > > >perform before others.  For example, an HR entry screen might contain
> > > >a field for salary.  You would validate that the field contains a
> > > >valid String that can be converted into a double, and you'd also make
> > > >sure it doesn't exceed certain bounds (like, say, USD 10,000,000 for a
> > > >junior programmer).  If the field doesn't contain a valid double,
> > > >there's no sense checking its value boundaries.  The field itself is
> > > >not syntactically valid.  This level of validation is what's most
> > > >often assigned to the ActionForm.  Much of these can be
> > > >automated/declared and oftentimes the Action doesn't even need to
> > > >participate.  Hence, we let the ActionForm carry out this part, and if
> > > >it fails at this level, we don't even bother calling the Action.
> > > >
> > > >Hubert
> > > >
> > > >On Fri, 18 Mar 2005 17:17:39 +0000, Lawrie Gallardo
> > > ><[EMAIL PROTECTED]> wrote:
> > > > > I'm still relatively new to Struts, but I can't help but feel that
> > > > > validation would be better performed by Action classes rather than
> > > > > ActionForm classes.
> > > > >
> > > > > It seems to me that, ideally, you want
> > > > > 1. Validation,
> > > > > 2. Transformations (ie convert separate day, month and year HTML
> >fields
> > > >to
> > > > > Java Date object), and
> > > > > 3. Mapping of ActionForm fields (/HTML parameters) to Domain POJOs /
> > > >DTOs
> > > > > to all be configured in the same config file (to minimise
> >duplication)
> > > >and
> > > > > to be implemented in the same class rather than scattered between
> > > >multiple
> > > > > config files and classes.
> > > > >
> > > > > Now, if my understanding is correct:
> > > > > 1. There is always a one-to-one mapping between an ActionForm and an
> > > > > ActionMapping,
> > > > > 2. Struts best practice is to have each Action class handle all
> >possible
> > > > > operations for the HTML request it deals with using
> >DispatchLookupAction
> > > >or
> > > > > something similar,
> > > > > 3. Almost noone creates ActionForms manually any more - they use
> > > > > DynaActionForm (or validating variations of this). And for those who
> >do
> > > > > still create ActionForms manually, they don't offer anything in the
> >way
> > > >of
> > > > > reuse, and are basically throw-away classes.
> > > > >
> > > > > Now if this is the case, would it not be better to have the
> >ActionForm
> > > >as
> > > > > basically a dum data holder and have the validation method in the
> >Action
> > > > > classes instead? The strus-config.xml file could contain all the
> > > >required
> > > > > declarative validation, transformation and mapping info, and the
> >Action
> > > > > class could contain any validation, transformation, and mapping
> > > >operations
> > > > > that were too complicated to be set up declaratively.
> > > > >
> > > > > Is it just down to design decisions made in early versions of Struts
> >and
> > > > > backward compatibility that things are the way they are? Or are
> >there
> > > >good
> > > > > arguments for having the validation method in ActionForm? Am I
> >missing
> > > > > something here?
> > > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > >For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > > _________________________________________________________________
> > > It's fast, it's easy and it's free. Get MSN Messenger today!
> > > http://www.msn.co.uk/messenger
> > >
> > >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> _________________________________________________________________
> It's fast, it's easy and it's free. Get MSN Messenger today!
> http://www.msn.co.uk/messenger
> 
>

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

Reply via email to