Nice article. One thing I was hoping to learn from the article is how to write custom Validators that are decoupled from Struts, yet provide the same functionality as those validators shipped with Struts.
For instance, in the NewValidator class in the article there is a validateDrinkingAge(...) method that takes the following types as parameters:
Because of presence of ActionErrors, this NewValidator class is tied to Struts.
What happens when one day we decide to replace Struts with XYZ? We have to rewrite a piece of this Validator.
Because of presence of HttpServletRequest, this NewValidator is usable only in the Web App context. What happens if we want to use this Validator in a desktop application?
I am wondering how one would create a custom Validator that did not have these 2 dependencies (or at least not the Struts dependency).
If I write a custom Validator with a method such as:
How do I use this method in a Struts application without passing it instances Struts-specific classes, such as ActionErrors, and still somehow end up with error messages suitable for showing to the user, etc.?