• 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

which beanValidator should be used with constrain validation

 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

With spring mvc 3.0, I am confused about using BeanValidator with constrain validation.:



The beanValidator as shown above is confusing me, I can't find an import lib to use.
This example is referenced with an example in the following link:

http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303


Any suggestion is very appreciated.
Thanks
Sam
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
beanValidator is just the name he chose not the type. Validator is defined in javax.validation.Validator. You would use the factory to get an instance



Some containers will provide their own implementations of Validator which may or may not cause you problems if you wanted to force it to use the Hibernate validator implementation for example you could do something like this



Keep in mind the Validator is NOT thread safe. Validator Factories are.
 
sam White
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the solution, that works.
Do you know how to display the error message on jsp?

At the moment, when error occurs, the page returns to the page, but no error message shown up on the page.

Here is my jsp file:



Controller:



And... With the above controller code, how to combine the "general" binding result wiht the one shown in Violation into one?
Thanks
Sam
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep in mind the Validator is NOT thread safe. Validator Factories are.
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic