Using the Validator Framework with Struts
Subject:   Decoupling from Struts
Date:   2003-02-26 10:22:40
From:   anonymous2

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:
validateDrinkingAge(Object, Field)

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.?


1 to 2 of 2
  1. Decoupling from Struts
    2003-12-05 07:50:53  anonymous2 [View]

  2. Decoupling from Struts
    2003-06-26 10:30:07  anonymous2 [View]

1 to 2 of 2