This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • visitor validator
Skip to end of metadata
Go to start of metadata


The VisitorFieldValidator allows you to forward validation to object properties of your action using the object's own validation files. This allows you to use the ModelDriven development pattern and manage your validations for your models in one place, where they belong, next to your model classes. The VisitorFieldValidator can handle either simple Object properties, Collections of Objects, or Arrays.


  • fieldName - field name if plain-validator syntax is used, not needed if field-validator syntax is used
  • context - the context of which validation should take place. Optional
  • appendPrefix - the prefix to be added to field. Optional


Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'
       <!-- Plain Validator Syntax -->
       <validator type="visitor">
           <param name="fieldName">user</param>
           <param name="context">myContext</param>
           <param name="appendPrefix">true</param>

       <!-- Field Validator Syntax -->
       <field name="user">
          <field-validator type="visitor">
             <param name="context">myContext</param>
             <param name="appendPrefix">true</param>

In the example above, if the action's getUser() method return User object, XWork will look for User-myContext-validation.xml for the validators. Since appednPrefix is true, every field name will be prefixed with 'user' such that if the actual field name for 'name' is ''

  • No labels