0 Replies Latest reply on Jul 23, 2010 3:42 AM by Alessandro Martellucci

    how to validate params in form action method

    Alessandro Martellucci Newbie

      Hi to everyone.
      I'm trying to use Hibernate Validator (es. @Length, @NotNull, @Pattern, ..)
      for form params.
      If I use a Seam-style param passing, i.e. putting the params in the form action method call, the seam bean isn't able to validate the params values.

      I can't use the above annotations on the method sign.

      This is my situation:

      <h:form id="form">
           <h:inputText id="formParam" binding="#{requestScope.formParam}"
            required="true" requiredMessage="Missing Form Param!" />
           <h:commandButton action="#{seamBean.doStuff(requestScope.formParam.value)}"
            value="Do Stuff" type="submit" />

      @Length(min = 16, max = 16, message = "...")
      @NotEmpty(message = "....!")
      @NotNull(message = "...")
      @Pattern(regex = "....", message = ".....")
      public String printByCodiceFiscale(String formParam) {

      Using a JSF-style, i.e. the form params become seam bean's properties, it works because I move the annotations on top of the declared java class properties.

      Thank you in advance