WebWork relies on XWork validation framework to enable the application of input validation rules to your Actions before they are executed. This section only provides the bare minimum to get you started and focuses on WebWork's extension of the XWork validators to support client-side validation.
Note |
---|
There is also an option for Client Side (Javascript and/or AJAX) based validation, please see Client Side Validation for more information. |
Examples
- Basic Validation
- Client Validation
- AJAX Validation
- Using Field Validators
- Using Non Field Validators
- Using Visitor Field Validator
Validators available in WebWork
Note |
---|
|
When using a Field Validator, Field Validator Syntax is ALWAYS preferable than using the Plain Validator Syntax as it facilitates grouping of field-validators according to fields. This is very handy especially if a field needs to have many field-validators which is almost always the case. Examples: #validatortypes |
- required validator
- requiredstring validator
- int validator
- date validator
- expression validator
- fieldexpression validator
- email validator
- url validator
- visitor validator
- conversion validator
- stringlength validator
- regex validator
Registering Validators
Wiki Markup |
---|
{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
This list declares all the validators that comes with WebWork.
Wiki Markup |
---|
{snippet:id=validators-default|javadoc=false|lang=xml|url=https://xwork.dev.java.net/source/browse/*checkout*/xwork/src/java/com/opensymphony/xwork/validator/validators/default.xml?content-type=text%2Fplain} |
Note |
---|
|
Wiki Markup |
---|
{snippet:id=information|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
|
Warning |
---|
|
Wiki Markup |
---|
{snippet:id=warning|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
|
Turning on Validation
Wiki Markup |
---|
{snippet:id=turningOnValidators|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=exTurnOnValidators|javadoc=true|lang=xml|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Note: The default validationWorkflowStack already includes this.
Validator Scopes
Wiki Markup |
---|
{snippet:id=fieldValidators|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=nonFieldValidators|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Notes
Wiki Markup |
---|
{snippet:id=validatorsNote|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Defining Validation Rules
Wiki Markup |
---|
{snippet:id=validationRules1|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=exValidationRules1|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=validationRules2|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=validationRules3|javadoc=true|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=exValidationRules3|javadoc=true|lang=xml|url=com.opensymphony.xwork.validator.ValidatorFactory} |
Wiki Markup |
---|
{snippet:id=validationRules|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Validator Flavour
Wiki Markup |
---|
{snippet:id=validatorFlavours|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Non-Field Validator Vs Field-Validator
Anchor |
---|
| validatortypes |
---|
| validatortypes |
---|
|
Wiki Markup |
---|
{snippet:id=validatorVsFieldValidators1|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=nonFieldValidatorUsingValidatorSyntax|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=fieldValidatorUsingValidatorSyntax|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=validatorVsFieldValidators2|javadoc=true|url=com.opensymphony.validator.xwork.Validator} |
Wiki Markup |
---|
{snippet:id=fieldValidatorUsingFieldValidatorSyntax|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=validatorVsFieldValidators3|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=similarVaidatorDeclaredInDiffSyntax|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Short-Curcuiting Validator
Wiki Markup |
---|
{snippet:id=shortCircuitingValidators1|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=exShortCircuitingValidators|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=shortCircuitingValidators2|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=scAndValidatorFlavours1|1=javadoc|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=exScAndValidatorFlavours|lang=xml|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
Wiki Markup |
---|
{snippet:id=scAndValidatorFlavours2|1=javadoc|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |
How Validators of an Action Are found
Wiki Markup |
---|
{snippet:id=howXworkFindsValidatorForAction|javadoc=true|url=com.opensymphony.xwork.validator.Validator} |