3 Replies Latest reply on Mar 21, 2011 1:50 PM by Lukáš Fryč

    graphValidator triggered before fields set?

    Pawel Stawicki Newbie



      I am using graphValidator in my page to validate if all the percentages sum up to 100. The problem is, when my validation method (annotated with @AssertTrue) is called, percentage fields are not set yet. So, of course, it doesn't pass validation.


      My page (tags like <tr>, <td> etc. omitted):


          <rich:graphValidator id="percents" value="#{bean}">         

            <h:inputText id="govPercent" value="#{bean.gov}">

              <f:convertNumber type="number"/>


            <h:message for="govPercent" errorClass="invalid"/>

            <h:inputText id="manufacturePercent" value="#{bean.man}">

              <f:convertNumber type="number"/>


            <h:message for="manufacturePercent" errorClass="invalid"/>

            <h:message for="percents" errorClass="invalid"/>



      And bean:


        private Double gov;

        private Double man;


        //getters and setters omitted


        @AssertTrue(message = "{percentages_not_sum_to_100}")

        public boolean getPercentsSumTo100() {

          double sum = zeroForNull(gov)

                      + zeroForNull(man);

          return sum == 100;



      zeroForNull() is simple method returning 0 in case value is null, and value otherwise.


      I can see in debug, that getPercentSumTo100 method is called, but setters are not called when I fill in the fields on the page.


      I'm using richfaces