• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Custom Bean Validator Not Called

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 28750
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 (http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303). 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 (http://weblogs.java.net/blog/cayhorstmann/archive/2009/12/29/jsf-20-and-tomcat).

If this needs to be moved to a different part of the forum than the JSF section, feel free to move it.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic