The Struts/Commons validator offers a very nice approach in that it lets
you do "domain" type validations up front. The validations are defined
in an XML file, and the library can then generate both JavaScript and
server-side Java validations from the same source. 

This is a helpful precursor to the next step, which is converting the
HTTP string parameters into typed properties. 

Most business API classes are written to take native types rather than
Strings representing a native type, so obtaining string data from a user
that *can* be converted to a native type is really a presentation layer
task. 

This is the end of validation, but the beginning of bringing the data up
from the presentation layer and into the business layer. The business
layer will then perform its own validations, but usually on typed data
rather than raw Strings. 

Like some other Commons products, the Commons Validation is being
integrated into the nightly build and slated for the 1.1 timeframe. The
Commons version is unreleased, but David's original site is here:

http://home.earthlink.net/~dwinterfeldt/


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/



"Tom Klaasen (TeleRelay)" wrote:
> 
> FWIW, according to the book "professional site programming" which I
> started to read recently, the recommended design pattern is to do
> "basic" validation in the ActionForm (is a number, is a date), and the
> more business-oriented validation in the Action (is a positive smaller
> than 10, is a date AD).
> 
> Ted should be able to correct me on this :)
> tomK
> 
> > -----Original Message-----
> > From: Dick Starr [mailto:[EMAIL PROTECTED]]
> > Sent: woensdag 23 januari 2002 21:46
> > To: struts-user
> > Subject: Should all validation be done in the Action class
> > instead of the ActionForm class?
> >
> >
> > I'm new to web apps / struts and wanting know if there is any
> > performance
> > reason to do initial validation in the ActionForm class (via
> > validate="true"). It seems to me that all validation should
> > be done in the
> > Action class since then all the validation is in one section
> > of code and
> > since the Action class gets called anyway. Also, I heard that
> > there are
> > tools to automatically generate the ActionForm classes, which might be
> > another argument to not stick any additional code in them (in
> > case you want
> > to re-generate them). Just wondering ...
> >
> > Thanks,
> >
> > Dick Starr
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-> [EMAIL PROTECTED]>
> > For
> > additional commands,
> > e-mail: <mailto:[EMAIL PROTECTED]>
> >
> >
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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

Reply via email to