2 Replies Latest reply on Apr 8, 2009 7:20 PM by Franco Fernandes

    Date range checks on rich:calendar

    Franco Fernandes Novice

      I have 2 dates (start and end) bound to rich:calendar
      What I am trying to achieve is -
      - if one of the dates is entered and the other is blank, then it is required.
      - if both are entered, they should be validated for correctness - start should not be later than end.

      I don't have a problem with the second. I just can't seem to get the required attribute generated correctly for these dates.

      Here is my markup

      <s:decorate id="featureStartDateDecoration" >
      <rich:calendar id="featureStartDate"
       value="#{catalogItemHome.instance.featureStartDate}"
       datePattern="MM/dd/yyyy"
       inputSize="10"
       process="featureEndDate"
       ajaxSingle="true"
       required="#{catalogItemHome.instance.featureEndDate != null ? true : false}"
       requiredMessage="Feature start date is required if you enter end date"
       >
       <a4j:support event="onchanged" action="#{catalogItemHome.validateFeatureDateRange}"
       reRender="featureStartDateDecoration,featureEndDateDecoration"/>
      
      </rich:calendar>
      </s:decorate>
      
      <s:decorate id="featureEndDateDecoration" >
      <rich:calendar id="featureEndDate"
       value="#{catalogItemHome.instance.featureEndDate}"
       datePattern="MM/dd/yyyy"
       inputSize="10"
       process="featureStartDate"
       ajaxSingle="true"
       required="#{catalogItemHome.instance.featureStartDate != null ? true : false}"
       requiredMessage="Feature end date is required if you enter start date"
       >
       <a4j:support event="onchanged" action="#{catalogItemHome.validateFeatureDateRange}"
       reRender="featureStartDateDecoration,featureEndDateDecoration"/>
      </rich:calendar>
      </s:decorate>



      Let's say I have values for these dates when I start

      I go to start date, and hit Clean button on the calendar to clear the value.
      So it's required message is shown because end date still has a value. Ok.

      Now I clean the end date too and this time both fields required messages are displayed.

      Is it possible to do what I am doing or should I validate this at form level?

      using RF 3.3

      Thanks
      Franco