[Opensource] Struts Validation in Expresso
Peter A. Pilgrim
peterp at xenonsoft.demon.co.uk
Fri Mar 12 12:18:35 PST 2004
Raul DAVIDOVICH wrote:
> Hi all,
>
> I'm trying to implement field validation in Expresso using Commons
> Validator, in Struts' way.
>
> First I overriden the validate() method in DefaultForm, using a similar
> behaviour to the one found in ValidatorActionForm.The difference is that I
> made the validtion contexts relative to the state rather than to the action
> path; like Struts does.
>
> Next I wrote an ExpressoFieldChecks class which does the same as Struts'
> one but it can also use the DefaultForm's methods for accessing the fields
> to validate.
David
I am not sure where the failure is it. May be it is similar to the Struts
upload method. It does not work in Expresso at the moment, because
of the incompatibility with the input.
I presume you are allowing the Struts MVC to automatically the validate
the action form bean in the struts-config.xml file.
Have you tried making it work manually inside an Expresso Controller?
Get the ActionForm from the `ServletControllerRequest'. I believe the method
is:
org.apache.struts.action.ActionForm getForm()
Gets the action form as a convenience for pure Struts writer.
then call validate() on the form bean.
ActionErrors errors = formBean.validate( httpServletRequest, actionMapping );
See also
HttpServletRequest getHttpServletRequest()
Gets the http servlet response object Important: A Controller should only use this
method if strictly necessary, and not write output that is otherwise able to be handled with
inputs, outputs and transitions.
org.apache.struts.action.ActionMapping getMapping()
Gets the action mapping as a convenience for pure Struts writer.
>
> Up to here it works as expected.
>
> Now I'm stuck on how to forward back to the requesting state if the
> validation fails. I overrided the processValidate() method in
> ExpressoRequestProcessor, but I can't manage to figure out how to go back
> to the state who generated the form...
>
You might need to do this manually as above. The Struts ActionMapping has input JSP
to return the view for form submission. This is different from the original state.
> Any clues here will be very appreciated
>
> If anyone wants more information on this, feel free to ask me, I'll be glad
> to answer
>
>
> Best regards
>
> ---------------------------------------------------
> Raul Davidovich
> Responsable Informatique
> Cvitkovic & Associés Consultants
>
> (33) 1 45 15 40 68
> (33) 1 45 15 40 41 Fax
> -------------------------------------------------------
> http://www.caconcology.com
>
>
>
> _______________________________________________
> Opensource mailing list
> Opensource at jcorporate.com
> http://mailman.jcorporate.com/mailman/listinfo/opensource
>
>
--
Peter Pilgrim
__ _____ _____ _____
/ //__ // ___// ___/ + Serverside Java
/ /___/ // /__ / /__ + Struts
/ // ___// ___// ___/ + Expresso Committer
__/ // /__ / /__ / /__ + Independent Contractor
/___//____//____//____/ + Intrinsic Motivation
On Line Resume
||
\\===> `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''
More information about the Opensource
mailing list