2 Replies Latest reply on Jul 17, 2009 4:04 PM by alexsmirnov

    bean validation

    trevor.flanagan

      I have a question regarding bean validation on a inputtext component (RichFaces 3.3.1). My bean contains the following annotation:

      @NotEmpty
       @Length(min = 3, max = 3, message = "Field must be three characters")
       private String id = null;
      


      and my jspx contains the following -
      <h:inputText id="currCd"
      value="#{currencyModalPanelController.currencyBean.id}"
      disabled="#{currencyModalPanelController.idColDisabled}"
      valueChangeListener="#{currencyModalPanelController.hasBeenEdited}"
      binding="#{currencyModalPanelController.view.currCd}"
      required="true" >
      <rich:beanValidator/>
      <rich:ajaxValidator id="currCdAjxVal" event="onblur" />
      </h:inputText>



      The problem is that the bean validation for not null only works for me when I have no binding on the inputtext. Once I have a binding the validation only occurs for the length annotation. As a result I have had to add the required attribute to the input text. Why is this the case?

        • 1. Re: bean validation
          nbelaevski

          Hi,

          That's limitation of JSF 1.2. The issue is resolved in JSF 2.0.

          • 2. Re: bean validation
            alexsmirnov

            Do you create component instance in the binding by 'new' call ?
            Standard JSF input components do not call validation methods for an empty values. That behavior was changed for JSF 2.0 but RichFaces also redefines some UIInput based components that calls bean validator for all even null or empty values. The component type is same but classes are different.
            I suggest to change your code from 'new' to Application.createComponent calls.