Another aproach is to generate your ActionForms using Xdoclet so you don't
waste time generating them.

Also, I think it is a great idea to do sintactic validation using the
Commons Validator and then have some business/semantic validation in another
layer, the commons validator (combined with xdoclet) is really a big help to
validate simple stuff (like required fields).

-----Original Message-----
From: Hubert Rabago [mailto:[EMAIL PROTECTED]
Sent: Friday, March 18, 2005 11:40 AM
To: Struts Users Mailing List
Subject: Re: Wouldn't validation be better performed by Actions rather
than ActionForms?


Inline.

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.
> 

Hmm, you just described one use case for FormDef when coupled with its
Validator integration.  :)
https://formdef.dev.java.net
http://www.rabago.net/struts/formdef/manual.htm#combinedconfig


> Now, if my understanding is correct:
> 1. There is always a one-to-one mapping between an ActionForm and an
> ActionMapping,

An action form holds the request parameters that accompany a request. 
The most common use case is a form being submitted.  You submit each
<form> to one URL - that's why there's a one-to-one mapping.


> 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,

That certainly is one practice.  Personally I don't use that.  I
mostly use my own Action subclasses, or if I want dispatch
functionality, I used to use MappingDispatchAction.  Now I use the
ActionDispatcher class in
http://issues.apache.org/bugzilla/show_bug.cgi?id=31270 .


> 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.

My own rule has been, if the requirements can be fulfilled by a dyna
form, then that's what I use.  Otherwise, I use a manually created
ActionForm.  Whenever I have a manually created ActionForm, believe
me, they're certainly not throw-away.


Hubert

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

Reply via email to