• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Use validator framework or override validate()?

 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it considered better pratice to use validator framworks over validate()? Or are there situations where you should use both? thanks.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you ask me , i use the validator framework because its easy to use and form validation is quite easy as you dont have to write the code to validate the forms
Validate() is i use only if there is some logic that needs to be checked other than just checking the value..
and yes we might have to use both often

-thanks
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have mixed feelings about the Validator framework. After you put together a few utility methods to perform validation (validateRequiredString(), validateDate(), etc.) it is almost easier to just put the code in your validate() method. Another place where implementing validate methods is where you have forms that derive from a base class or forms that share chunks of data. With the Validator framework you pretty much have to repeat the same validation rules for each of these forms, where you can use shared code in Java.

The general rule of thumb on my projects have been to use the Validator framework for standard validation and put validation not covered by one of the existing rules in the validate method. In the latter case the code calls super.validate() so that the xml validation rules are also processed.

- Brent
reply
    Bookmark Topic Watch Topic
  • New Topic