6 Replies Latest reply on Dec 15, 2009 11:06 AM by Florian Duehring

    getData(...) of CalendarDataModel not called

    Florian Duehring Newbie

      Hi,

      I have a similar problem as described here:
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=146208 and here
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=148232:
      The getData() method of a customized CalendarDataModel isn't called when moving to a different month or year. Actually it's called only once while loading the page...

      Do you have a solution for this?

      Thanks

        • 3. Re: getData(...) of CalendarDataModel not called
          Florian Duehring Newbie

          Hi Nick,

           

          sure. Here's the code of the xhtml page:

           

          <rich:calendar
               value="#{calendarBean.date}"
               popup="false"
               showApplyButton="false"
               cellWidth="100px"
               cellHeight="100px"
               showWeeksBar="true"
               dataModel="#{calendarDataModel}"
               id="calendar_organizer"
               showFooter="false"
          >
               <a4j:outputPanel
                    layout="block"
                    id="cell"
                    style="height: 100%;"
               >
               <h:panelGrid columns="1">
               <h:outputText value="{day}" style="align:center"/>
               <h:outputText style="white-space:nowrap;" value="{data.shortDescription}" escape="false"/>
               <h:outputText value="{data.description}" escape="false"/>
               </h:outputText>
              </a4j:outputPanel>
               <a4j:support event="onchanged" reRender="calendar_todaysTasks,calendar_todaysAppointments" />
          </rich:calendar>
          

           

          Here's the getData()-implementation of the #{calendarDataModel} (request scope):

           

          public CalendarDataModelItem[] getData(Date[] dateArray) {
              if (dateArray == null) {
                  return null;
              }  
              items = new CalendarDataModelItem[dateArray.length];
              for (int i = 0; i < dateArray.length; i++) {
                  items[i] = createDataModelItem(dateArray[i]);
              }
              return items;
          }
          
          protected CalendarDataModelItem createDataModelItem(Date date) {
               CalendarDataModelItemImpl item = new CalendarDataModelItemImpl();
               ArrayList<IAppointment> appointments =
               this.sessionFassade.getAppointments(date);
               ArrayList<ITask> tasks =
               this.sessionFassade.getTasks(date);
               Map<String, String> data = new HashMap<String, String>();
               String appointmentOutput = "";
               for ( int i = 0; i < appointments.size(); i++){
                    if ( i > 0 ){
                         appointmentOutput += "<br />";
                    }
                    appointmentOutput += "&#187; [A]" + appointments.get(i).getSubject();
               }
               for ( int i = 0; i < tasks.size(); i++){
                    if ( appointments.size() > 0 ){
                         appointmentOutput += "<br />";
                    }
                    appointmentOutput += "&#187; [T]" + tasks.get(i).getSubject();
               }
               data.put("shortDescription", appointmentOutput);
               data.put("description", "");
               Calendar c = Calendar.getInstance();
               c.setTime(date);
               item.setDay(c.get(Calendar.DAY_OF_MONTH));
               item.setEnabled(true);
               item.setStyleClass("rel-hol");
               item.setData(data);
               return item;
          }
          
          • 4. Re: getData(...) of CalendarDataModel not called
            Florian Duehring Newbie

            Some more details regarding the environment:

            Richfaces 3.3.2 SR1

            Myfaces 1.2.8

            Tomact 6.0.18

            • 5. Re: getData(...) of CalendarDataModel not called
              Ilya Shaikovsky Master

              you not defined mode.

              default mode value is client so no requests occurs on month change.

              in client mode if preload range dates not defined - data loaded only for current month.

               

              so you have to define mode="ajax" or define preload range for client side calendar.

              • 6. Re: getData(...) of CalendarDataModel not called
                Florian Duehring Newbie
                Great, thanks. Now it works as expected.