I'm not a veteran, but I am pretty familiar with Validator and
ValidatorForm, so since it is late evening (EST anyway) any you may not get
quick responses, I'll take a shot...

It doesn't have anything to do with validations being simple or complex.
The isse is that if you create an ActionForm, you must code your own
validations, both those that require nothing more than the data in the form
and those that require data from the database.  If you use the
ValidatorForm, you can CONFIGURE the former type of validations in
validations.xml, and AVOID CODING it in the validate method of the
ActionForm.  Of course, if no rule already exists in validation-rules.xml
to do your desired validation, you will have to code your own custom rule.
I'm sure others will chime in with pros and cons.  I haven't done enough of
either to form many opinions on it yet, other that writing your own code
would seem to provide you far more flexibility and power, but is more work
and may not be as bullet-proof as this supposedly well tested validation
framework and validation rules.    For the latter type of validations
(complex) where you have to rely on seriously complex business rules and/or
access the database, I think you're going to end up coding that within the
Action/Validator Form regardless.




                                                                                
                                        
                      "Daniel Watrous"                                          
                                        
                      <[EMAIL PROTECTED]        To:       "Struts Users Mailing 
List" <user@struts.apache.org>           
                      .com>                    cc:                              
                                        
                                               Subject:  validator vs business 
logic                                    
                      01/18/2005 08:13                                          
                                        
                      PM                                                        
                                        
                      Please respond to                                         
                                        
                      "Struts Users                                             
                                        
                      Mailing List"                                             
                                        
                                                                                
                                        
                                                                                
                                        




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?

How many of you use ValidatorForm instead of or in conjunction with
ActionForm?

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]

Reply via email to