-
1. Re: Hibernate validation not working in Seam...
thejavafreak Aug 20, 2007 2:24 AM (in response to anticlockwise5)You should annotate your field with @NotNull since you have a minimum requirement for the input
-
2. Re: Hibernate validation not working in Seam...
anticlockwise5 Aug 20, 2007 3:23 AM (in response to anticlockwise5)"thejavafreak" wrote:
You should annotate your field with @NotNull since you have a minimum requirement for the input
Thanks for the reply, but adding a @NotNull does not solve the problem though, and the same thing happens to other validator annotations such as @Email... -
3. Re: Hibernate validation not working in Seam...
thejavafreak Aug 20, 2007 4:29 AM (in response to anticlockwise5)How about do the not-null checking on the JSF form first? That way user are forced the have an input before the form is submitted
-
4. Re: Hibernate validation not working in Seam...
anticlockwise5 Aug 20, 2007 6:54 AM (in response to anticlockwise5)"thejavafreak" wrote:
How about do the not-null checking on the JSF form first? That way user are forced the have an input before the form is submitted
Well, that would work yes, but shouldn't @Email annotation allow users to not enter any values? Also, in the hibernate validator source code, I saw that null values and empty values are allowed in the EmailValidator and should both pass the validation. -
5. Re: Hibernate validation not working in Seam...
anticlockwise5 Aug 20, 2007 11:05 AM (in response to anticlockwise5)I've tried lots of ways and none of them worked, the problem still exists, not sure if it has something to do with JBoss Seam's integration with Hibernate Validator...
-
6. Re: Hibernate validation not working in Seam...
tynor Aug 20, 2007 11:27 AM (in response to anticlockwise5)When you say you've checked the Hibernate Validators sources and think it should work properly, are you sure you are looking at the version you are actually using? In JBoss 4.2.1, I had to installer newer hibernate jars in order to get a working @Email validator as detailed here:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=115318
Also, be aware that if you don't mark a field "required" on the input control, JSF will not submit a blank/empty text field for validation. Hibernate, however, will check for non-nullness, etc. when you do an update or persist, and this can cause an exception at persist time. So you need to be very careful to keep your validator annotations compatible with "required" (or non-required) input controls. I find this aspect of JSF (non)validation to be very error prone and wish it could be fixed, but it seems to be entrenched in the JSF lifecycle design, so we are forced to work around it. -
7. Re: Hibernate validation not working in Seam...
stephen.friedrich Aug 20, 2007 11:34 AM (in response to anticlockwise5)In this thread http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88789 Pete Muir says
It's a limitation in JSF. If JSF component has (required=false && value=null) then any validators attached won't be fired.
Gavin says the same in http://www.jboss.com/index.html?module=bb&op=viewtopic&t=84975
I have no idea why this is so, but I think we can trust the authorities on this. -
8. Re: Hibernate validation not working in Seam...
pmuir Aug 20, 2007 11:39 AM (in response to anticlockwise5)Read the SeamProblemsFAQ.
As for why, it is a limitation of the JSF spec, hopefully we can get it rectified for JSF 2.0. -
9. Re: Hibernate validation not working in Seam...
anticlockwise5 Aug 20, 2007 11:53 AM (in response to anticlockwise5)Thanks for all the replies :)
I'll just add a "required" to each of the field to be validated for the time being. Thanks guys