• 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

where to put validation?

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the best place to put your business logic validations?
One of the things is to override the validate method in your ActionForm class.Is it advisable to put business logic validations here?
And if you put your validate method there,is saveErrors method called by framework itself?
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jitesh Sinha:
What is the best place to put your business logic validations?



Best place tu put business logic validation , i think , put in validate() method in ActionForm.

But in my work, I used both validation in ActionForm, and validation in client -side (javascript).

Originally posted by Jitesh Sinha:

And if you put your validate method there,is saveErrors method called by framework itself?



In validate() method of ActionForm, You MUST keep all error in ActionErrors.
If have some errors , you can check and display error in jsp page (<html:errors/>
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I check values in form using javascript, I may implement validate() method for server validation also, for instance



And I put my business logic validations,such as retrieve the password from database and compare to password in form, in Action class.
[ July 30, 2004: Message edited by: Surasak Leenapongpanit ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set validation to false and then call the validation method on the ActionForm from your Action. This way, you can add additional business logic errors from the Action.

Just another option.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic