9 Replies Latest reply on Dec 2, 2009 12:00 AM by asookazian

    Hibernate Validator on non-entity seam backing beans

    bogdanminciu.bogdan.minciu.yahoo.com

      Hello,


      I would like to use Hibernate Validator on some non-entity Seam backing beans. So, I have this bean:


      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("productCreate")
      public class CreateProductBean implements LocalCreateProduct {
      
          @NotNull
          @Length(min = 3)
          private String productName;
      
          @NotNull
          @Length(min = 9)
          private String productCode;
      
          public CreateProductBean() {
          }
      
      //getters and setters omited
          
          @Remove
          public void remove() {
          }
      
          @Override
          public String toString() {
              return null;
          }
      
          @Override
          public boolean equals(Object o) {
              return false;
          }
      }
      



      and this facelet page:


      <h:form>
          <h:messages globalOnly="true" styleClass="message"/>
      
          <s:decorate id="productNameDecorate" template="layout/edit.xhtml">
              <ui:define name="label">Product name: </ui:define>
              <h:inputText id="productName" value="#{productCreate.productName}"/>
          </s:decorate>
      
          <s:decorate id="productCodeDecorate" template="layout/edit.xhtml">
              <ui:define name="label">Product code: </ui:define>
              <h:inputText id="productCode" value="#{productCreate.productCode}"/>
          </s:decorate>
      
          <h:commandButton id="ok" value="Create Product" />
      </h:form>
      



      The edit.xhtml template is the generated one. When the form is submitted, the validation process seems not to be reached. There is no validation-failed message; the fields are reported as valid.


      Is it possible to use Hibernate Validator on simple, non-entity Seam backing beans like the one above? What am I missing? Any help would be highly appreciated.




      Many thanks in advance,


      Bogdan.