Validator Framework
·
org.apache.struts.validation.FieldChecks
Class contains the all methods & Logics for Performing the Validations
·
validation-rules.xml(Pre-Difined) - Contains the all methods details
in Field class
·
validator.xml(User
Defiend) – Contains the all FormBean Properires
Common Steps:
1.
Copy validations-rules.xml to WEB-INF
2.
Define Validation.xml and save in
WEB-INF
3.
Configure ValidatorPlugin in
struts-congig.xml
4.
Extend our FormBean class from
ValidatorForm class
5.
Create Properties File
Rules
1.
Required : errors.required
2.
Minlength : errors. Minlength
3.
Maxlength : errors.maxlength
4.
Mask : errors.invalid
5.
Date Rule : errors.date
6.
email rule : (no need to configure in validation.xml) errors.email
7.
Integer rule : (no need of configure in validation.xml) errors.integer
Steps
to Develop:
1.
Create
login.jsp with <html:errors/>
2.
Create
LoginForm bean class by extending ValidatorForm
3.
Write
setter/getter
4.
Create
LoginAction
5.
Copy
validator-rules.xml
6.
Implement
validation.xml
7.
Configure
ValidatorPlugIn in struts-config.xml