You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 51 Next »

Struts Action 2 relies on a validation framework provided by [WW:XWork] 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 our extension of the XWork validators to support client-side validation.

There is also an option for Client Side (Javascript and/or AJAX) based validation, please see Client Side Validation for more information.

Examples

  1. Basic Validation
  2. Client Validation
  3. AJAX Validation
  4. Using Field Validators
  5. Using Non Field Validators
  6. Using Visitor Field Validator

Bundled Validators

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

  1. required validator
  2. requiredstring validator
  3. int validator
  4. date validator
  5. expression validator
  6. fieldexpression validator
  7. email validator
  8. url validator
  9. visitor validator
  10. conversion validator
  11. stringlength validator
  12. regex validator

Registering Validators

Error formatting macro: snippet: java.lang.NullPointerException

This list declares all the validators that comes with the framework.

Error formatting macro: snippet: java.lang.NullPointerException

Note

Error formatting macro: snippet: java.lang.NullPointerException

Warning

Error formatting macro: snippet: java.lang.NullPointerException

Turning on Validation

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

Note: The default validationWorkflowStack already includes this.

Validator Scopes

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

Notes

Error formatting macro: snippet: java.lang.NullPointerException

Defining Validation Rules

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

Validator Flavour

Error formatting macro: snippet: java.lang.NullPointerException

Non-Field Validator Vs Field-Validator

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

Short-Circuiting Validator

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

How Validators of an Action are Found

Error formatting macro: snippet: java.lang.NullPointerException

Resources

WebWork Validation

Next: Localization

  • No labels