Uploaded image for project: 'ZK Calendar'
  1. ZK Calendar
  2. ZKCAL-36

Refresh model make calendar broken.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.1.3
    • 2.1.2, 2.1.1
    • None

      as title, test case:

      zul page:

      <zk>
      	<window border="0"
      		apply="test.CalendarMainCtrl">
      		<button id="setModel" style="cursor:pointer"
      			label="set model" />
      		<calendars id="calendars" firstDayOfWeek="Sunday" mold="default"
      			height="540px">
      		</calendars>
      	</window>
      </zk>
      

      composer

      package test;
      
      import java.util.Calendar;
      import java.util.Date;
      
      import org.zkoss.calendar.Calendars;
      import org.zkoss.calendar.api.CalendarEvent;
      import org.zkoss.calendar.impl.SimpleCalendarModel;
      import org.zkoss.zk.ui.Component;
      import org.zkoss.zk.ui.util.GenericForwardComposer;
      
      public class CalendarMainCtrl extends GenericForwardComposer<Component> {
          private static final long serialVersionUID = 6970953044952813761L;
      
          private Calendars calendars;
      
      
          @Override
          public void doAfterCompose(Component comp) throws Exception {
              super.doAfterCompose(comp);
              setCalendarsModel();
          }
      
          public void onClick$setModel() {
          	setCalendarsModel();
          }
      
          private void setCalendarsModel() {
              SimpleCalendarModel calendarModel = (SimpleCalendarModel) calendars.getModel();
              if (calendarModel == null) {
                  calendarModel = new SimpleCalendarModel();
              } else {
              	calendarModel.clear();
              }
              calendarModel.add(new CalendarEvent() {
                  
                  @Override
                  public boolean isLocked() {
                      return true;
                  }
                  
                  @Override
                  public String getZclass() {
                      return "z-calevent";
                  }
                  
                  @Override
                  public String getTitle() {
                      return "name";
                  }
                  
                  @Override
                  public String getHeaderColor() {
                      return "#446688";
                  }
                  
                  @Override
                  public Date getEndDate() {
                      Date date = new Date();
                      Calendar calendar = Calendar.getInstance();
                      calendar.setTime(date);
                      calendar.add(Calendar.DATE, 5);
                      calendar.set(Calendar.HOUR_OF_DAY, 0);
                      calendar.set(Calendar.MINUTE, 0);
                      calendar.set(Calendar.SECOND, 0);
                      calendar.set(Calendar.MILLISECOND, 0);
                      return calendar.getTime();
                  }
                  
                  @Override
                  public String getContentColor() {
                      return "#212312";
                  }
                  
                  @Override
                  public String getContent() {
                      return "test";
                  }
                  
                  @Override
                  public Date getBeginDate() {
                      Date date = new Date();
                      Calendar calendar = Calendar.getInstance();
                      calendar.setTime(date);
                      calendar.add(Calendar.DATE, 4);
                      calendar.set(Calendar.HOUR_OF_DAY, 0);
                      calendar.set(Calendar.MINUTE, 0);
                      calendar.set(Calendar.SECOND, 0);
                      calendar.set(Calendar.MILLISECOND, 0);
                      return calendar.getTime();
                  }
              });
              calendars.setModel(calendarModel);
          }
      
      }
      
      

            vincentjian vincentjian
            benbai benbai
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: