-
1. Re: Constraint @Length acts differently on Seam vs. Hibernate
admin.admin.email.tld Aug 7, 2008 12:17 AM (in response to bartj07)you need to use <s:validate> or <s:validateAll> in your xhtml to trigger the hibernate validator(s) on the client-side as well. are you doing that? -
2. Re: Constraint @Length acts differently on Seam vs. Hibernate
bartj07 Aug 7, 2008 5:29 AM (in response to bartj07)Yup, my validation stuff works fine except for this case. The problem is that it validates on the ui how I want, but not at persist-time.
Specifically:1) nothing filled in, doesn't throw validation error (required="false")
2) filled in, but below or above min and max, throws validation error
3) filled in, and between min and max, doesn't throw validation error
At persist-time, 1) throws an error.
-
3. Re: Constraint @Length acts differently on Seam vs. Hibernate
pmuir Aug 8, 2008 2:37 PM (in response to bartj07)This is a mismatch between JSF and Hibernate validator, JSF sets an empty value as an empty String, not as null (which would pass the validation). Your best bet is to either write a custom length validator that allows this, or write some logic in your backing bean.
-
4. Re: Constraint @Length acts differently on Seam vs. Hibernate
epbernard Aug 8, 2008 3:51 PM (in response to bartj07)Pete, you mean when the string is "", Seam (JSF really) does not run the validator? but still JSF place the value in the domain model? -
5. Re: Constraint @Length acts differently on Seam vs. Hibernate
pmuir Aug 8, 2008 3:59 PM (in response to bartj07)Exactly.
Also, if the field is empty in a JSF/facelet page, "" is set on the model, not null.
-
6. Re: Constraint @Length acts differently on Seam vs. Hibernate
christian.bauer Aug 8, 2008 4:57 PM (in response to bartj07)Yes, this is a big bug in JSF. I have a few TODO curses in my source in places where I translate from "" to null. This should be fixed in JSF 2.0, Pete.
-
7. Re: Constraint @Length acts differently on Seam vs. Hibernate
epbernard Aug 8, 2008 10:11 PM (in response to bartj07)I agree with Christian. This behavior is just leaking a web form presentation limitations into the rest of the application.
null is a much more sensible value. -
8. Re: Constraint @Length acts differently on Seam vs. Hibernate
pmuir Aug 9, 2008 7:52 PM (in response to bartj07)Ok, I will raise it with the JSF EG.