From Documentation

Jump to: navigation, search





The CalendarEvent interface

It is important when working with the calendar to effectively manage the event data of the calendar. The event data is contained in a class which implements CalendarEvent.

An implementing Object should provide the following functions:

MethodUsage
getBeginDate Returns the beginning date of the calendar event.
getEndDate Returns the end date of the calendar event.(exclusive)
getTitle Returns the title of the calendar event.
getContent Returns the content of the calendar event.
getHeaderColor Returns the color of the header in the calendar event. Only allows the value being recognized by CSS.
getContentColor Returns the color of the content in the calendar event. Only allows the value being recognized by CSS.
getZclass Returns the zclass of the calendar event.
isLocked Returns whether the calendar event is locked or not.


A CalendarEvent implementation

The code snippet below details a basic class which would fulfill the contract of the CalendarEvent interface.

import java.util.Date;
import org.zkoss.calendar.api.CalendarEvent;

/**
 * A non functional implementation of the CalendarEvent
 * 
 */
public class MyCalendarEvent implements CalendarEvent {

    public Date getBeginDate() {
        return new Date();
    }

    public Date getEndDate() {
        return new Date();
    }

    public String getTitle() {
        return "";
    }

    public String getContent() {
        return "";
    }

    public String getHeaderColor() {
        return "";
    }

    public String getContentColor() {
        return "";
    }

    public String getZclass() {
        return "";
    }

    public boolean isLocked() {
        return false;
    }

}

In a real implementation the above class is useless as it does not contain any meaningful data. We could expand on the class so it could save state information. However, ZK Calendar already provides a class named SimpleCalendarEvent which provides the relevant functionality for you. This class is discussed here.


The example project is at Github



Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.