6 Replies Latest reply on Aug 21, 2008 3:05 PM by shadowcreeper

    How to change the current date in calendar control from own

      Hi!
      Can anyone provide solution able to change the selected date/time in calendar control from own JavaScript code.
      I'd not see any suitable functions for Richfaces.Control object.
      Thanks!

        • 1. Re: How to change the current date in calendar control from
          • 2. Re: How to change the current date in calendar control from

             

            "SergeySmirnov" wrote:
            See spec at: http://anonsvn.jboss.org/repos/richfaces/trunk/ui/calendar/design/funcspec/, section #6. JavaScript API


            Thanks for fast reply!
            I analyze this document and found the needed functions, but the calendar control generates the following HTML:

            <div id="MyForm:calendarDate" style="z-index:3; ">
            new Calendar('MyForm:calendarDate', {
             ...
             currentDate: new Date(2007,7,27),
             selectedDate: new Date(2007,7,27),
             datePattern: 'MMM d, yyyy',
             jointPoint: 'bottom-left',
             direction: 'bottom-right',
             toolTipMode:'batch',
             boundaryDatesMode:'inactive',
             popup: false,
             ...
             minDaysInFirstWeek: 1}).load()
            </div>
            


            As you see this code is creating an unnamed anonymous instance of class Calendar, and I can't to actuate for this instance.


            • 3. Re: How to change the current date in calendar control from
              ilya_shaikovsky

               

              <a4j:form id="form">
               <h:panelGroup id="test" columns="2" style="width: 300px">
               <h:selectBooleanCheckbox value="#{bean.check}">
               <a4j:support event="onchange" reRender="test" />
               <f:selectItem itemValue="true" itemLabel="Show" />
               <f:selectItem itemValue="false" itemLabel="Hide" />
               </h:selectBooleanCheckbox>
              
               <rich:calendar popup="true"
               rendered="#{!bean.check}" value="#{bean.date}" id="c"/>
               <a onclick="$('form:c').component.doExpand()" href="#">Show</a>
               </h:panelGroup>
               </a4j:form>


              This is the example of the component popup showing from the external link.

              • 4. Re: How to change the current date in calendar control from

                 


                This is the example of the component popup showing from the external link.


                Very big thanks! I'll try this.


                • 5. Re: How to change the current date in calendar control from
                  anandramv

                  hi,
                  Can you please give an example to use any one of the following javascript API, for the Rich Faces Calendar component.

                  disableDate(date)
                  enableDates(date[])
                  disableDates(date[])

                  i tried several possibilites of using this method, but it didn't work.

                  disableDate(event,new Date(2008,7,19))
                  disableDate(new Date(2008,7,19))


                  CODE REFERENCE :

                  <f:view>
                   <h:form id="formID" >
                   <rich:calendar id="calendarID" value="#{patientMedicalReportsPageBean.selectedDate}"
                   locale="#{patientMedicalReportsPageBean.locale}" popup="#{patientMedicalReportsPageBean.popup}"
                   datePattern="#{patientMedicalReportsPageBean.datePattern}" cellWidth="24px" cellHeight="22px" style="width:200px" isDayEnabled="enabledate()" onexpand="$('formID:calendarID').component.disableDate(new Date(2008,7,20))" />
                  <a4j:commandLink onclick="$('formID:calendarID').component.doExpand(event);alert(new Date(2008,7,20));$('formID:calendarID').component.disableDate(event,new Date(2008,7,15))" value="Expand"/>
                  
                   </h:form>
                   </f:view>



                  Thank you in advance,

                  Anand

                  • 6. Re: How to change the current date in calendar control from
                    shadowcreeper

                    I did it by creating a CalendarDataModel with CalendarDataModelItems but this only works if calendar is not controlled by the client. :(