4 Replies Latest reply on Jan 17, 2008 8:50 AM by Pete Muir

    s:validateAll don't works.

    virgulino ferreira Newbie

      Hi People,

      Seam isn't validating fields, even when I wrap the input controls with s:validateAll.
      When a validation error occurs, s:validateAll don't intercepts the error and my DAO throws an org.hibernate.validator.InvalidStateException.

      I'm using...
      - Hibernate 3.2.5
      - Hibernate Annotations 3.3.0.GA
      - Hibernate Validator 3.0.0.GA
      - Seam 2.0.0.GA
      - JBoss AS 4.2.2.GA

      P.S: I don't generate my app with sean-gen because I'm using Maven2.

        • 1. Re: s:validateAll don't works.
          virgulino ferreira Newbie

          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.
            Thomas März Newbie

            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.html
            Note: 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.
              Neil McFarlane Novice

              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.
                Pete Muir Master

                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 :(