3 Replies Latest reply on May 10, 2011 7:12 PM by Caesar Ralf Franz Hoppen

    rich:graphValidator update values after bean validation fails

    Caesar Ralf Franz Hoppen Newbie

      Maybe I understood it wrong, but what I was imagining is that if bean validation with a graphValidator failed the values would be reseted to their original state, but that is not happening. I have case that works like this:

       

      The user needs to enter values for a threshold. It has two main values: lower limit and upper limit. The limits must be valid long values and lower limit can not be bigger that upper limit. So, I have a component like this:

       

       

      public class AbsoluteValueThreshold extends AbstractThreshold implements Cloneable {
          // lower and upper limit mutators with validations skipped for simplicity
      
          // BEAN VALIDATION
          @AssertTrue(message = "Invalid threshold limits.")
          public boolean isValidLimits() {
              return super.isValidLimits();
          }
      }
      

       

      And in my xhtml I have a component like this:

       

                  <rich:graphValidator value="#{threshold}" >
                      <h:panelGrid columns="2">
                          <h:outputText value="#{thresholdGroupLabels['LOWER_LIMIT']}" title="#{thresholdGroupLabels['LOWER_LIMIT']}"/>
                          <h:inputText value="#{threshold.lowerLimit}" tabindex="1"/>
      
                          <h:outputText value="#{thresholdGroupLabels['UPPER_LIMIT']}" />
                          <h:inputText value="#{threshold.upperLimit}" title="#{thresholdGroupLabels['UPPER_LIMIT']}" tabindex="2"/>
      
                          <h:outputText value="#{thresholdGroupLabels['SEVERITY']}" />
                          <h:selectOneMenu value="#{threshold.severity}" tabindex="3">
                              <f:converter converterId="SeverityConverter"/>
                              <f:selectItems value="#{controller.severityItems}" />
                          </h:selectOneMenu>
                      </h:panelGrid>
                  </rich:graphValidator>
      

       

      When the value of the limit is invalid (not long), the value is reseted to its original state as expected because it did not pass validation phase. But when the bean is invalid (lower limit is bigger than upper limit), the validation fails but the model is still updated with the new values. I understood that the use of clone would prevent this, but am I assuming wrong? Is there a clean way to make what I want, or I will need to clone the object by myself and then copy the values if the validation is successful?

       

       

      I am using JSF 1.2, richfaces 3.3.3, hibernate validator 4.0.1.FINAL

       

      Sorry for my english