up to ValidatorFAQ

How to use validator with dispatchAction


if you want to use different validation rules with the validator you have to declare different action elements in your struts-config.xml file (using the same action class if you want). for that you have to use the (Dyna)ValidatorActionForm.

another means is to validate your form in the methods of your DispatchAction class as in this example:


{{{ <action path="/logon/action/logon"


{{{ ActionErrors errors = new ActionErrors();

<eliemedeiros@hotmail.com> Or you could also write a thin wrapper around the validationframework to validate a single field at the time. For instance the following code carries out the validation of the form field at the same time it retrieves its value:

{{{ import java.util.ArrayList;

                while (it.hasNext()) { 

                 return form.get(key); 


This can be called in the following manner from an action extending DispatchAction:

      public ActionForward viewForm (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 

                        return (mapping.getInputForm() ); 

Hope this helps someone.


up to ValidatorFAQ

ValidatorDispatchAction (last edited 2009-09-20 23:12:15 by localhost)