2 Replies Latest reply on Nov 16, 2009 6:04 AM by Ilya Shaikovsky

    Calendar and validation

    Pawel Duda Newbie

      Hi,

      I am trying to validate a calendar on picking a new date by attaching a <f:validator> to it. This works fine unless the user presses the "clean" button.. When this happens, the validator doesn't launch (probably no event sent).

      I was trying attaching <a4j:support> with various events from DevGuide but the closest I got was launching the validator but with old value (instead of expected null).

      How to perform a validation for a calendar on the date pick/clean? I'm not interested in setting "required=true" since this will later be a form validation. And this should work without additional buttons - on date pick/clean event.

      Thanks!

        • 1. Re: Calendar and validation
          Pawel Duda Newbie

          Here's the code I am using:

          <rich:calendar
           id="taskStartDate"
           popup="true"
           value="#{taskViewBean.filterStartDate}"
           datePattern="#{sessionBean.calendarPattern}"
           boundaryDatesMode="active"
           showApplyButton="true">
           <h:outputText value="{day}">
           </h:outputText>
           <f:validator validatorId="datumValidator"/>
           <a4j:support event="onchanged"/>
          </rich:calendar>
          


          • 2. Re: Calendar and validation
            Ilya Shaikovsky Master

            using slightly modified richfaces-demo sample

             <rich:messages></rich:messages>
             <rich:calendar value="#{calendarBean.selectedDate}"
             locale="#{calendarBean.locale}"
             popup="#{calendarBean.popup}"
             datePattern="#{calendarBean.pattern}"
             showApplyButton="#{calendarBean.showApply}" cellWidth="24px" cellHeight="22px" style="width:200px"
             required="true">
             <a4j:support event="onchanged"/>
             </rich:calendar>
            

            I'm getting messages appears just after I clicking clean. 3.3.1 snapshot.