Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Validation > Using Visitor Field Validator
Added by tm_jee, last edited by Ted Husted on Sep 10, 2006  (view change)

Description

The followings show a simple example using Webwork's Field Validators

Step 1

Create the jsp page

<s:fielderror />

<s:form method="POST" action="submitVisitorValidatorsExamples" namespace="/validation">
    <s:textfield name="user.name" label="User Name" />
    <s:textfield name="user.age" label="User Age" />
    <s:textfield name="user.birthday" label="Birthday" />
    <s:submit label="Submit" />
</s:form>

Step 2

Create the actoin class

public class VisitorValidatorsExampleAction extends AbstractValidationActionSupport {

    private static final long serialVersionUID = 4375454086939598216L;

    private User user;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}

Step 3

Create the validator.xml.

An error occurred: http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/VisitorValidatorsExampleAction-submitVisitorValidatorsExamples-validation.xml. The system administrator has been notified.