6 Replies Latest reply on Feb 17, 2010 3:21 PM by Md. Kamruzzaman kamrul

    Hibernate Validation setup problem

    Joseph Miller Newbie

      Hi. I'm trying to get the Hibernate Validation annotations working in my app...

      I have model objects with annotations like:

      @Length( min = 5, max = 10 )
      private String _testField;

      But my form doesn't seem to be triggering those validations, only the JSF one which specifies if the field is required or not...

      form page looks like (there is a <rich:messages> component in the template..) :

      <s:div id="test-field-container">
        <table class="formtable">
          <ui:decorate template="/layout/form-field.xhtml">
            <ui:define name="label">Test Field</ui:define>
            <h:inputText id="test-field-input" value="${booking.testField}" required="true">
              <rich:ajaxValidator reRender="test-field-container" event="onblur"/>

      or with <ajax:support reRender="test-field-container" event="onblur" ajaxSingle="true" bypassUpdates="true"/> instead of the <rich:ajaxValidator../>

      I have in my persistence.xml:

      <persistence-unit name="AppName">
             <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
             <property name="jboss.entity.manager.factory.jndi.name" value="java:/BookItEntityManagerFactory"/>

      and components.xml:

         name="entityManager" auto-create="true"

      The Datasource is set up via a standard JBoss -ds.xml file. I'm running Jboss 4.2.2 (but could move to 5 if I really really needed to).

      I read somewhere you need a Seam-managed persistence context in order for the validations to work? Is this not set up like the above? I can run the code through a debugger, and I see the validation code isn't even being hit at all :(

      Any help would be very greatly appreciated, thanks :)