Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Validation > Using Non Field Validators |
The followings show a simple example using Webwork's Non Field Validators
Create the jsp page
<s:actionerror /> <s:form method="POST" action="submitNonFieldValidatorsExamples" namespace="/validation"> <s:textfield name="someText" label="Some Text" /> <s:textfield name="someTextRetype" label="Retype Some Text" /> <s:textfield name="someTextRetypeAgain" label="Retype Some Text Again" /> <s:submit label="Submit" /> </s:form>
Create the action class
public class NonFieldValidatorsExampleAction extends AbstractValidationActionSupport { private static final long serialVersionUID = -524460368233581186L; private String someText; private String someTextRetype; private String someTextRetypeAgain; public String getSomeText() { return someText; } public void setSomeText(String someText) { this.someText = someText; } public String getSomeTextRetype() { return someTextRetype; } public void setSomeTextRetype(String someTextRetype) { this.someTextRetype = someTextRetype; } public String getSomeTextRetypeAgain() { return someTextRetypeAgain; } public void setSomeTextRetypeAgain(String someTextRetypeAgain) { this.someTextRetypeAgain = someTextRetypeAgain; } }
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/NonFieldValidatorsExampleAction-submitNonFieldValidatorsExamples-validation.xml. The system administrator has been notified.