-
1. Re: s:validateAll don't works.
leandro3.marinho Jan 16, 2008 12:32 PM (in response to leandro3.marinho)Excuse me, s:validateAll is work, but there are something I don't know.
I annoted my property like this:@Length (min=5, message="Invalid Name") public String getName{...}
If I fill the input control linked with this property with a name less then 5 lethers, s:validateAll show the message "Invalid Name" and it doesn't try update the model, but if I DON'T fill this field, the s:validateAll skips this validation and update the model, but Hibernate catch the invalid property, throws "org.hibernate.validator.InvalidStateException" and rollback the transaction.
Question:
If s:validateAll and hibernate use the same version of hibernate validator, why did s:validateAll accept this property and hibernate doesn't? -
2. Re: s:validateAll don't works.
lundegaard Jan 16, 2008 12:48 PM (in response to leandro3.marinho)Adding required="true" should work:
<h:inputText value="#{name}" required="true"/>
See also http://docs.jboss.com/seam/2.0.1.CR1/reference/en/html/validation.htmlNote: specifying @NotNull on the model does not eliminate the requirement for required="true" to appear on the control! This is due to a limitation of the JSF validation architecture.
-
3. Re: s:validateAll don't works.
oberiko Jan 16, 2008 1:12 PM (in response to leandro3.marinho)This one caught me up (for about an hour or so) as well.
There is no validation done on blank fields.
Another problem is that blank fields are passed not as null, but as zero-length strings, so they'll sneak by any @NotNull annotations in both the presentation and business logic layer (making me question their usefulness).
Any idea if these issues are being looked after in the next version of Seam and/or JSF? I'd imagine that the second problem could be fixed pretty easily by lumping blank Strings in with null values by default; this could be disabled with "@NotNull(allowEmptyString=true)" or so. -
4. Re: s:validateAll don't works.
pmuir Jan 17, 2008 8:50 AM (in response to leandro3.marinho)This isn't a problem with Hibernate Validator, but with JSF, which doesn't run validation on empty fields. It requires a specification revision (JSF2) for it to be fixed :(