struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hutchison, Jeff" <j...@inst.strykercorp.com>
Subject Re: AW: AW: ANNOUNCEMENT: New JAKARTA-STRUTS Subproject
Date Wed, 14 Jun 2000 13:45:12 GMT
I'm extracting a portion of this from a long message posted to
struts-user because I wanted to comment on the development of the
FormBeans.

McClanahan, Craig wrote (I think):

> > Self-validating form beans sound cool at first blush, but consider
> > one issue about the process flow -- one of the roles of the form
> > bean itself is to faithfully represent the last set of input
> > fields that the user entered (whether the whole transaction is
> > semantically valid or not).  If the setter methods in your form
> > bean, for example, were to through IllegalArgumentException on
> > invalid values, your form bean would not be completely up to date
> > -- so that when you redisplayed the the form to the user again, it
> > wouldn't show the bad value that he/she actually entered.
> > I would suggest that validation be done either in the action class
> > itself, or in the "data access layer" bean or EJB that actually
> > represents your business objects.

Nestel, Frank wrote:
 
> Not sure if we are thinking about the same thing, I liked the
> approach in the "Advanced form processing using JSP" artivle by
> Govind Seshadri on JavaWorld. Extending that idea every FormBean
> should be required to have a validate() method which returns a data
> structure (Hashtable) about postion and type of error...

I agree, self-validating beans do sound cool.  I think the validate()
approach mentioned by Frank might be useful.  I'm reminded of two
different types of validation that Brett McLaughlin mentioned in a
presentation I saw at the O'Reilly Java conference earlier this year.

Coarse Grained Validation - generic validation of data types: required,
numeric, date, phone, email, etc...  This might be appropriate for
validation within either the browser (using JavaScript) or in a FormBean
validate() method.  For the validate() approach, each setter can
optionally call a superclass addValidationError() method, and the
validate() method can check to see if any errors were added and return a
boolean signalling success or failure.

Fine Grained Validation - very specific validation of business rules:
probably best done in the data access layer.

-jh

-- 
Jeff Hutchison <jhut@inst.strykercorp.com>
Stryker Instruments Kalamazoo, MI




Mime
View raw message