Search code examples
struts-1struts-validation

Difference between validatorform and validator action form


When should we use ValidatorForm, ValidatorActionForm, and their dynamic variants in struts based applications?


Solution

  • The difference is that the validation rules of a ValidatorActionForm are not assigned to the action form but to the action (/path-to-action.do). So it is possible to reuse a bean in multiple actions but to define different validations for each action.

    <form-validation>
        <formset>
            <!-- validation mapping for action /example1 -->
            <form name="/example1">
                ...
            </form>
        </formset>
        <formset>
            <!-- validation mapping for action /example2 -->
            <form name="/example2">
                ...
            </form>
        </formset>
    </form-validation>
    

    See also: