Professional Documents
Culture Documents
PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information.
PDF generated at: Mon, 22 Mar 2010 08:53:13 CET
Contents
Articles
ZK Calendar Essentials
ZK Calendar Essentials/Introduction
11
12
13
14
15
17
18
20
21
22
References
Article Sources and Contributors
25
26
ZK Calendar Essentials
ZK Calendar Essentials
<CollectionIndex>Documentation:Books/ZK_Calendar_Essentials</CollectionIndex>
ZK Calendar Essentials/Introduction
ZK Calendar is a Google Calendar like Ajax component that integrates rich and intuitive scheduling functionality
into enterprise web applications using pure Java. One of the main benefits of ZK Calendar is it can be embedded into
existing Java applications with minimal effort. The calendar facilitates interaction with other Ajax components and
the ability to customize functionality and styling.
ZK Calendar boasts all the advanced features of a modern day calendar such as daily, weekly, and monthly views,
drag-n-drop, multiple time zones, and permission control.
page="ZK
Calendar
Prerequisites
Downloaded ZK 5 CE (or higher) from [1]
Downloaded ZK Calendar 2.0 from [2]
References
[1] http:/ / www. zkoss. org/ download/ zk. dsp
[2] http:/ / www. zkoss. org/ download/ zkcalendar. dsp
[3] http:/ / www. zkoss. org/ download/ zkstudio. dsp
The
bare <calendars> declaration takes the following default values: <calendars firstDayOfWeek="Sunday"
mold="default" >
page="ZK
Calendar
ZK Calendar Attributes
The following table details ZK Calendars attributes and their usage.
Attribute
readonly
Usage
Sets whether it is readonly
Default Value
false
firstDayOfWeek Sets what the first day of the week is; e.g., SUNDAY in the
U.S., MONDAY in France
system default
currentDate
days
dateFormatter
Sets the date formatter. In fact, there are five places in the
calendar must have different date display
<javadoc>org.zkoss.calendar.impl.SimpleDateFormatter</javadoc>
model
null
mold
default
The best way to understand how attributes work is to follow an example. In this example we will concentrate on the
"mold" attribute.
By just changing one attribute ZK affords us exceptional power. But how do we change this attribute? The next
section explains how.
Setting attributes
We are able to set attributes in a zul file or Java file. The following examples outline how to do this.
In ZUL Files
<calendars id="calendar" height="80%" firstDayOfWeek="Sunday"
timeZone="California=PDT-8" mold="default"
readonly="true" />
In Java Files
calendar.setMold("default");
calendar.setTimeZone("California=PDT-8");
calendar.setFirstDayOfWeek("Sunday");
calendar.setReadonly(true);
page="ZK
Calendar
Usage
getBeginDate
getEndDate
getTitle
getContent
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
isLocked
A CalendarEvent implementation
The code snippet below details a basic class which would fulfill the contract of the <javadoc
type="interface">org.zkoss.calendar.api.CalendarEvent</javadoc> interface.
import java.util.Date;
import org.zkoss.calendar.api.CalendarEvent;
/**
* A non functional implementation of the CalendarEvent
*
*/
public class MyCalendarEvent implements CalendarEvent {
10
11
Usage
getCaptionByDayOfWeek
getCaptionByTimeOfDay
getCaptionByDate
Each function enables us to customize the appearance of the calendar at any opportunity. Implementing an interface
such as this is excellent if you require fine grained control. If you do not require such level of control then ZK
Calendar provides you with an implementation.
12
References
[1] http:/ / en. wikipedia. org/ wiki/ UTC
13
ZK Calendar Essentials/Working with ZK Calendar/Displaying ZK Calendar Event Data/Storing Event Data in Memory
few
random
events
in
the
14
ZK Calendar Essentials/Working with ZK Calendar/Displaying ZK Calendar Event Data/Storing Event Data in Memory
return sce;
}
public void createData() {
scm = new SimpleCalendarModel();
for(int i=0; i<3; i++) {
CalendarEvent ce = createRandomEvent();
addToModel(ce);
}
}
This code can then be incorporated to function as the in memory model for ZK Calendar. We discuss this in
Presenting Event Data
15
16
17
page="ZK
Calendar
18
org.zkoss.zk.ui.util.GenericForwardComposer;
org.zkoss.zul.Button;
org.zkoss.zul.Textbox;
org.zkoss.zul.Vbox;
19
This section demonstrated a simple way to implement the ZK MVC pattern, in the next, we'll see how this technique
is adapted in making a ZK Calendar.
id="calendarID">
20
Usage
stopClearGhost
clearGhost
getBeginDate
Returns the updated beginning date. If the event name is onEventEdit, null is assumed
getEndDate
Returns the updated end date. If the event name is onEventEdit, null is assumed
getCalendarEvent Returns the calendar event. If the event name is onEventCreate, null is assumed
getX
getY
21
22
23
Submit:
<button id="btnAdd" label="Create" width="80px" height="24px"/>
</row>
</rows>
</grid>
</window>
</zk>
In calendar.zul,
define a ZK macro component named "BookEventDialog" and specify its corresponding ZUL file's URI, in this
case, just "bookEvent.zul"
<?component name="CreateDialog" macroURI="bookEvent.zul"?>
In
CalendarCtrl.java
(the
controller
<javadoc>org.zkoss.zk.ui.util.GenericForwardComposer</javadoc>)
class
that
extends
24
25
26