aspose file tools*
The moose likes Validation -JSR303 and the fly likes which beanValidator should be used with constrain validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java JSRs » Validation -JSR303
Bookmark "which beanValidator should be used with constrain validation" Watch "which beanValidator should be used with constrain validation" New topic
Author

which beanValidator should be used with constrain validation

sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 208
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
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

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.


[How To Ask Questions][Read before you PM me]
sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 208
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
honey free
Greenhorn

Joined: Dec 17, 2012
Posts: 1
Keep in mind the Validator is NOT thread safe. Validator Factories are.


"honey"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which beanValidator should be used with constrain validation
 
Similar Threads
No http://www.springmodules.org/validation/bean/validator
Using Richfaces client side validation on submit
wikipedia and reddit protesting web bills on wednesday
FacesMessage and ValidationMessages
Entity beans validation, how to know what constraint is being violated?