[Opensource] ActionForms and Validation
Peter A. Pilgrim
peterp at xenonsoft.demon.co.uk
Mon Jan 19 09:44:52 PST 2004
Mike Traum wrote:
> ControllerForm extends ActionForm, so you can extend that. Then you
> define that in struts-config.xml <form-beans/> and in the 'name'
> parameter of the action mapping. To validate, I believe you override the
> validate(ActionMapping mapping, HttpServletRequest request) method of
> ActionForm. Also, I believe you should use State.perform instead of
> State.run so that you'll have access to that form bean from the state.
>
> You can also use Expresso methods, such as State.addParameter(String
> newParam, boolean required, String mask, String maskError). See
> SimpleLoginController.java for an example of this.
>
> Or, there's State.setMask() & State.checkParamMasks(). Or,
> State.autoValidate() to validate data based on a DBObject definition.
>
> request.getParameter("name") is generally how you get a parameter in
> expresso. It's getting it from the ControllerRequest. If you use a
> custom ControllerForm, you'll want to use the form bean.
>
> hth,
> mike
>
David
Oh I am not sure because ValidatorForm extends ActionForm also. All three
(including ValidationForm) are concrete classes. If you want to use the
Struts Validator possibly a new class has to be created that inherits the
abilities of ActionForm, ValidatorForm and ConcreteForm. The so called
multiple inheritance DIAMOND in C++ in Java this time, unfortunately
it does not work in Java.
You can get access to the ActionForm associated with the Action
(Expresso Controller) it s in the Controller / ControllerRequest API.
ActionForm findControllerForm( ControllerRequest request )
Once you have a reference to the ActionForm, downcast it to the
ValidatorForm type and use the form bean.
In your controller you may have to explicitly call validate() method
on the form bean inside the Expresso controller.
Expresso does not do anything special with ActionForm really.
The `DefaultForm' is just a special form bean that adds abilities
to save and load Servlet properties across Http request. (I think)
>
> On Thu, 2004-01-15 at 09:14, Raul DAVIDOVICH wrote:
>
>>Hi all,
>>
>>I'm trying to implement form validation in expresso.
>>
>>In struts, one just needs to extend ValidatorForm instead of ActionForm and
>>the job is done.. but in expresso I'm having a real hard time to find out
>>how and where action forms are implemented so I can add this.
>>
>>Up to now I've been using request.getParameter("paramName") for retrieving
>>the fields from the page, and now that I look further I cannott find them
>>beeing mapped to an actionform anywhere.
>>
>>I did see that there are some methods in the controller for retrieving the
>>form from the request, but it's empty.
>>
>>
>>
>>if anyone can point me to where I can start looking it would be very
>>helpful.
>>
>>
>>Thanks in advance
>>
>>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://mail.jcorporate.com/mailman/listinfo/opensource
>>Archives: http://mail.jcorporate.com/pipermail/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