The framework provides an extensive but easy-to-use system for vetting data submitted by a form.
Presentation - Validating Input
Do we need to validate input? Can a validation framework help? Does validation affect workflow? Can we code custom Validators?
The validator framework provides a uniform approach to server-side and client-side validation.
- Manual Validation
- Validation Framework
- Validation Workflow
- Coding Validators
Workshop - Register extensions
Story: Values submitted by the Register form must be the correct type, and some values are required.
- Utilize the validation framework to confirm input without changing the server page
- Field Validator - type, message
- requiredstring, email, string-length, expression
- Create a validation configuration file ("Register-validation.xml) to realize the extensions to the Register Use Case
- Username and Password are required
- Password length must be at least 4 characters and no more than 10
- Full Name is required
- From Address and Reply To Addresses must be email addresses
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> <validators> </validators>
- Utilized the validation framework to validate input without changing the server page
- Add an "expression" validator to ensure the password and confirmation password match.
- In the Register.jsp form tag, add the attribute "validate=true". See any difference? Check the HTML source!
- Add a cancel button to the form. Try going directly to Welcome, or adding a cancel method that does the same.