struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phase Web and Multimedia" <m...@phase.ws>
Subject RE: [Gurus Invited] Why not an Action Based Validator?
Date Wed, 15 Jan 2003 14:56:45 GMT
Well, all this would be a mute point if there weren't times when we have to
populate collections in an ActionForm so that our jsp page doesn't blow up.
If I have errors in my validate on the form level I have to populate
collections. Those collections are gathered from my resource layer which
requires that I access the business layer in order to create them. If my
validation code is in two places this makes for more maintenance (i.e.
validation in form and action).

I understand the whole semantic vs. business-rule validation (good
clarification). But, it also stands true that with a useful tool like
Validator we could handle the validation in the Action class or in the
ActionForm. It doesn't matter where the validation happens really. Because,
we are reusing the validator validation rules... not the validate method in
the ActionForm. There are cases where I actually want different validation
to happen on a form than at other times. With Validator you use
ValidatorActionForm and create validation specific to the action mapping.
So, why not make validation available in the Action also. This does not seem
to be breaking in reusability rules.

I don't know if my point is being clearly communicated. IF YOU USE VALIDATOR
AND VALIDATOR COULD BE USED FROM AN ACTION then the same validation will
happen whether it is in you ValidatorActionForm or Action class. The only
difference would be that "business-rule" validation could be handled along
with the "semantic". Besides, with Validator the semantic validation is
ALREADY ABSTRACTED. Why not make the Validator flexible enough to be used
from within the Action by creating a ValidatorAction class with the
underlying code and method to use the Validator. Simplify... Simplify...
Simplify... :-D


Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: s.frank@vierundsechzig.de [mailto:s.frank@vierundsechzig.de]
Sent: Wednesday, January 15, 2003 6:41 AM
To: struts-user@jakarta.apache.org; tib@i-trade.hu
Subject: AW: [Gurus Invited] Why not an Action Based Validator?


I seriously doubt, that the approach " handle (ALL) types of validation in
the SAME class" is practical: The Validation taht takes place in the from
class happens a semantic level: It just checks, wether the entered values
are in a valid format(this even applies to mandatory field, as NULL is not
a valid format for the field) - exactly where a validation against
business-rules happens is highly-architecture dependent and so you cannot
even be sure, that an action-class is the architectural right place to
perform validation: There are a lot of projects where the action classes
either work as BusinessDelegates or access BusinessDelegates, that
delegate their calls to ejb or whatever. In simpler, less-tiered system
you may have action-classes that do the validation against businessrules
themself.

What indeed may be missing is a unified approach not handle validation but
how to handle validation errors:
1) semantic errors: The Action is never invoked, request is immerdiately
returned to input.
2) business-rule violations: They finally arrive in the action and you
have to put set some kind of errors and forward to an errorhandler page.

The questions seems to me, if there is a) need to unify this handling b)
possibility to implement such a unified handling


 --- Ursprüngliche Nachricht ---
Datum: 15.01.2003 11:44
Von: Gemes Tibor <tib@i-trade.hu>
An: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
Betreff: Re: [Gurus Invited] Why not an Action Based Validator?

> 2003. január 15. 11:30 dátummal Phase Web and Multimedia ezt írtad: > >
But that is my whole point. Complex validation or not. Why don't we
handle
> > both types of validation in the SAME class. I don't want to beat this
into
> > the ground. But, it just seems organizationaly better in my mind to
handle
> > validation on the Action level. With all the great minds on this
project I
> > am certain that there is a good design reason for placing validate in
the
> > ActionForm. I am just curious what it is.
>
> I use the validator framework to ensure that the Form property (type
String)
> can be converted to BigDecimal/Date/int.
>
> If I reuse a Form I want to reuse these validations as well. This can be
done
> if the validation is coupled with the form imho.
>
> No one is forced to use this approach however. You can implement the
other one
> by creating a new BaseForm base class which has the a function with the
same
> functionality as the ValidatorActionForm.validate(...) under a different

> name.  Set up the validator framework properly. This ensures client side

> validations, but the server side validation won't occure. Now call the
> renamed form's validation function in your BaseAction's validate
method.
>
> Tib
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message