File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Custom Bean Validator Not Called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom Bean Validator Not Called" Watch "Custom Bean Validator Not Called" New topic

Custom Bean Validator Not Called

Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
This class level bean validation call is not being called.

It is being called like this:

The only way I can get it to be called is when I place it on a field. Any ideas what is going on?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

It sounds like you're attempting to attach a Validator to a container element. That doesn't work. Validators can only be applied to individual control elements.

I wrote one of these sorts of validators. It was for the traditional "enter-the-password-twice" control pair. What I had to do was attach it to one of the password controls, which then supplied its value to the validator. For the matching value in the other control, I (the validator) had to retrieve that control from the view tree, get its value, compare to the value passed in and then throw the ValidationException if they didn't match.

An IDE is no substitute for an Intelligent Developer.
Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
What? I don't think we are on the same page, Tim.

This is a bean validation validator that uses the Hibernate bean validation annotation APIs. It has no access to the view tree (nor should it). There are examples of how this can be attached to a class so it shouldn't be a problem ( Unfortunately, I can't get it to work anywhere other than on a field or method. It isn't called on a constructor for me either.

If it helps, I am using Apache Tomcat 6 and have downloaded hibernate-validator-4.1.0.jar to patch it to support annotations in EE 6. More information on what I did is shown here under Bean Validation (

If this needs to be moved to a different part of the forum than the JSF section, feel free to move it.
I agree. Here's the link:
subject: Custom Bean Validator Not Called
It's not a secret anymore!