up to ValidatorFAQ


How to use validator with dispatchAction

Answer(s)

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:

struts-config.xml:

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

LogonAction.java:

{{{ 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.

</eliemedeiros@hotmail.com>


up to ValidatorFAQ