2 Replies Latest reply on Mar 9, 2006 8:44 PM by sguimont

    Feature suggestion - Use Hibernate validation framework with

    sguimont

      The Hibernate validation with Seam is very usefull because you don't need to add the validation rules within the presentation (facelets/JSF view).

      Sometime, I cannot use an Entity bean with the @Valid annotation. So, I add fields in my Stateful session bean, but with this approach I need to add my validation everywhere and cannot reuse validation component easily.

      It will be great, if we can use the same annotations from the Hibernate validation framework in that context too.

      Here's an example:

      @Stateful
      @Name("damFinder")
      @Interceptors(SeamInterceptor.class)
      public class DamFinderImpl implements IDamFinder {
       private String code;
      
       @NotNull
       @Length(min = 1, max = 100)
       public String getCode() {
       return this.code;
       }
      
       public void setCode(String aCode) {
       this.code = aCode;
       }
      
       @IfInvalid(outcome = Outcome.REDISPLAY)
       public String search() {
       // DO THE SEARCH, and the fields are validated
       }
      


      I don't know how much work this feature requires but I'm sure it will helps me to write my code faster and removes the code duplication.

      We can push the feature a little further and adjust the maxlenght attribute of the JSF inputText tag the same way Hibernate adjust his the property mapping with annotations.

      I know I'm a dreamer ;-) maybe one day!