You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/02/18 04:35:00 UTC
DO NOT REPLY [Bug 17150] New: -
Validation rules not reusable across layers, eg. EJBs
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17150>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17150
Validation rules not reusable across layers, eg. EJBs
Summary: Validation rules not reusable across layers, eg. EJBs
Product: Struts
Version: 1.1 Beta 3
Platform: All
OS/Version: All
Status: NEW
Severity: Enhancement
Priority: Other
Component: Validator Framework
AssignedTo: struts-dev@jakarta.apache.org
ReportedBy: Anton.Marsden@solnet.co.nz
I'd like to be able to pass a ValidatorForm to/from the servlet/EJB and perform
the same validation checks on it. Rationale: I don't want to validate the same
pre-conditions in two layers. I don't want to write the same validation rule
twice.
Basically, the problem I have is that HttpServletRequest and ActionErrors are
passed into the static FieldChecks methods (ValidationActions). The validation
itself does not require HttpServletRequest or the ActionErrors, except that it
creates the ActionErrors objects. The request is used to grab the Locale and
MessageResources information, which in turn is used to construct the
ActionErrors.
My suggestions are to:
- remove the Struts-specific stuff from the static validation methods (in the
FieldChecks class).
- generate the ActionErrors _after_ the Validator.validate() has been called
(using the returned ValidatorResults object and the current HttpServletRequest).
This should keep the validation itself independent of Struts and usable by
other layers.
Things to consider are:
- is it sensible/practical for ValidationActions to depend on the request
object?
- how can another layer use the ValidatorForm easily? Should the
validatorResults member be exposed? Would a method like "ValidatorResults
validate()" be sensible?
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org