Daniel Watrous wrote:
The main difference is that ValidatorForm and ValidatorActionForm (and their dynamic counterparts DynaValidatorForm and DynaValidatorActionForm) cooperate with the Validator plugin, giving you declarative validation, as opposed to programmatic validation (as in ActionForm and DynaActionForm). Obviously if you choose programmatic validation, you are going to have more control, and you could, as you suggest, encroach on business logic. But that doesn't mean you should or will.Hello All,
As I am working through the details of my first Struts application I am getting a little stuck on the Validator idea. It would seem that I can implement each form in my application as EITHER an ActionForm or a ValidatorForm. The action form has a validate method included for the purpose of validating input on a small scale (apearantly). From what I can gather, the ValidatorForm is used to perform more complex validation.
It seems then that the ValidatorForm begins to encroach on business logic (this is supported by the fact that ValidatorForm is not required for a Struts application). It seems that any complex validations should be left to the business Model, and not included in the Controller or View. It is entirely possible that I am missing something. What are your opinions?I think you are correct. So you will have two levels of validation (at least). You will eliminate needless processing of unreasonable values at the ActionForm level (preventing flow from ever reaching the manager layer), and you perform more complex validation at the manager layer.
Since the validation is simpler at the ActionForm level, I find that there isn't much reason to use a programmatic approach there. Why write rules to determine if values can be converted to Date, Integer, etc.? Use the declarative validation for rules that general (because they're already all written for you) and eliminate a lot of code. Use programmatic validation (and throw Exceptions that cause forwarding back to the input page) at the manager layer, where business logic is necessary.
How many of you use ValidatorForm instead of or in conjunction with ActionForm?
I use ValidatorForm (until I have time to learn to use the dynamic forms).
Erik
Do you see it providing some feature outside of the business model and specific to the Controller or View?
Daniel
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]