0 Replies Latest reply on Mar 19, 2010 8:50 AM by grundor

    Problem with CalendarDataModel getData() combined with timeZone attribute

      We are using the rich:calendar control in an organizer type fashion similar to what is done in the RichFaces demo.

       

      I have found that when I use the timeZone attribute to specify the desired timezone of the client, the block of dates passed into getData() is incorrect.

       

      For example when I initially display the calendar, the first call to getData() is correct - we are currently in March, so date[0] passed to getData is March 1 EST, and date[30] is correctly set to March 31 EDT.  Now when I click the < button to browse to the previous month in the calendar, getData is passed an incorrect array of dates - date[0] is set to January 2 EST (instead of February 1) and date[29] is set to January 30 EST.  Essentially the start date is 1 month less than it should be and 1 day more.

       

      The dates are off in a similar fashion no matter what method I use to browse to a different month of the calendar.

      The server is running under EDT and the timeZone being specified to the calendar is PDT.

       

      If I remove the timeZone attribute things start working as expected.

       

      Here is my code where I create the calendar:

      <rich:calendar popup="false" cellWidth="107px" 
           showFooter="false" showApplyButton="false" showWeeksBar="false"
           dataModel="#{calendarDataModel}"
           styleClass="organizer" mode="ajax"
           id="organizer" timeZone="#{timeZone}">
           <h:outputText value="{day}" style="font-size: 11px; font-weight:bold"/>
           <a4j:outputPanel layout="block" id="cell">
                <h:panelGrid columns="1" width="100%">
                     <h:outputText escape="false" value="{description}"/>
                </h:panelGrid>
           </a4j:outputPanel>
      </rich:calendar>

       

      And the relevant parts of calendarDataModel class:

       

      @Name("calendarDataModel")
      @Scope(ScopeType.CONVERSATION)
      public class CalendarDataModelImpl implements CalendarDataModel, java.io.Serializable {
          private static final long serialVersionUID = -6553800482303371625L;

          private CalendarDataModelItem[] items;
             
          @SuppressWarnings("unchecked")
          public CalendarDataModelItem[] getData(Date[] dateArray) {
              if ((dateArray == null) || (dateArray.length == 0)) {
                  return null;
              }

           

             // Creates eventHash of events in current month (removed)
             
              // Now build out calendar data model
              items = new CalendarDataModelItem[dateArray.length];
              for (int i = 0; i < dateArray.length; i++) {
                  items[i] = createDataModelItem(dateArray[i], eventHash.get(orgDateTime.getStartOfDay(dateArray[i])));
              }
          }
          return items;
      }

       

      Have I stumbled on a bug or could I be doing something wrong here?