1 Reply Latest reply on Aug 28, 2007 11:32 AM by Pete Muir

    s:validateAll PersistentClassConstraint

    Martin Hoffmann Newbie

      Hello,

      I have a problem when using a Hibernate Validator with PersistentClassConstraint and the s:validateAll Tag.

      When accessing a property of a class which uses this validator within a JSF Page an error occurs due that the Validation Exception is not handled by the s:validateAll Tag. The exception is thrown when the entityManager tries to commit the entity.

      Is there a way to validate the whole entity before commiting?

      I tried to solve the problem by using a custom JSF validator but in that case it seams that I'm losing some state, because the EntityHome instance returns false for the mehod isManaged after a wrong validation.


      I'm using jBoss SEAM 1.2.1.GA and code generated by "seam generate-entities".

      The custom hibernate validator annotation:

      @ValidatorClass(SerialValidator.class)
      @Target(value = ElementType.TYPE)
      @Retention(RetentionPolicy.RUNTIME)
      @Documented
      public @interface Serial {
       String message() default "Wrong Serial";
      }
      


      The entity class:
      @Entity
      @Table(name = "machine")
      @Name("machine")
      @Serial
      public class Machine implements java.io.Serializable
      ...
      


      JSF code of one property, which is checked by the validator:
      <s:decorate id="serialDecoration" template="/layout/edit.xhtml">
       <ui:define name="label">#{messages.serial}</ui:define>
       <h:inputText id="serial" value="#{machineHome.instance.serial}"
       required="true">
       <a:support event="onblur" reRender="machine" />
       </h:inputText>
      </s:decorate>