File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes validate two propertis with only one custom validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "validate two propertis with only one custom validator" Watch "validate two propertis with only one custom validator" New topic
Author

validate two propertis with only one custom validator

gianluca gian
Ranch Hand

Joined: Aug 14, 2009
Posts: 31
hello, I have a problem with validation. Is it possible to validate two properties of a bean using only one ConstraintValidator? I have something like the following:


inside the CheckSomeBeanPropertiesValidator I call the service SomeApplicationService that returns some data searched calling findBySearchBean. Instead to have to call more than one customized ConstraintValidator (and more than one findBySearchBean) is it possible to call only one time the service and check two different properties?

Thanks

bye
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

Please UseCodeTags when posting code it makes it easier to read. I have added them for you so you can see the difference it makes.

It looks like your question is how to create an annotation that allows you to validate multiple fields. There is a good explanation of that here:
http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303


[How To Ask Questions][Read before you PM me]
gianluca gian
Ranch Hand

Joined: Aug 14, 2009
Posts: 31
Yes in that way source code is much better. I will read what you suggested me soon, I think it's right what I was looking for. Thank you. Bye
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validate two propertis with only one custom validator