Re: possible pattern for validation of page
Tuesday, August 30, 2005 09:50 AM
There are a few ways to accomplish this:
1. Using Struts, you can use the Validator.
2. Using a custom servlet, you can use if statements (not recommended).
3. Using Spring, you can wire Interceptor objects that can intercept and validate the "posted" data before it reaches your controller object.
4. You can use AJAX and perform validation as the person enters data in each field (tedious).
Whatever you choose, I'd recommend separating the validation code from your controller objects. The controller should only take the information and route to the business tier and should not concern itself with validation.
Validation logic can also be in the form of a rules engine to get around the if statements.