Beruflich Dokumente
Kultur Dokumente
ZK TM
December 2008
Potix Corporation
Copyright © Potix Corporation. All rights reserved.
The material in this document is for information only and is subject to change without notice. While reasonable efforts
have been made to assure its accuracy, Potix Corporation assumes no liability resulting from errors or omissions in this
document, or from the use of the information contained herein.
Potix Corporation may have patents, patent applications, copyright or other intellectual property rights covering the
subject matter of this document. The furnishing of this document does not give you any license to these patents,
copyrights or other intellectual property.
Potix Corporation reserves the right to make changes in the product design without reservation and without notification
to its users.
The Potix logo and ZK are trademarks of Potix Corporation.
All other product names are trademarks, registered trademarks, or trade names of their
respective owners.
Introduction................................................................................................................5
About ZK Studio.........................................................................................................5
Installation.................................................................................................................8
Prerequisite...............................................................................................................8
Application Servers.................................................................................................9
Install ZK Studio........................................................................................................9
Download ZK Library:............................................................................................11
Configure ZK Library:............................................................................................11
Features of ZK Studio................................................................................................26
ZUL Editor...............................................................................................................26
Syntax Check.......................................................................................................28
Content Assistance...............................................................................................30
Hyperlink Navigation.............................................................................................33
WYSIWYG Development........................................................................................37
Name Filtering......................................................................................................39
Preference................................................................................................................44
Global Preference.....................................................................................................44
Services..............................................................................................................44
Usage Issue.............................................................................................................56
Appendix C................................................................................................................59
Uninstallation...........................................................................................................59
About ZK Studio
ZK Studio is a Eclipse IDE plug-in to help developers developing Direct Rich Internet
Application (RIA) Web Application with ZK Ajax Framework rapidly. With the aid of ZK Studio,
you can develop ZK Web Application easily and quickly.
(1)ZUL Editor: ZUL Editor is your main editor for editing *.zul & *.zhtml file.
(2)Ajax Widget Palette: Provides a Drag & Drop component palette toolbox for ZUL File.
(4)Hierarchy View of Web Page: It presents a tree structure view of the content in the
currently selected ZUL Editor.
(5)Property View of UI tag: It shows a list of applicable attribute & their value of currently
selected node in ZUL Editor or Hierarchy View of Web Page.
New ZK Wizard: there are two main feature, one is to help you create or modify an existing
Eclipse Dynamic Web Project to support ZK Ajax framework, the other one, New ZUL File
Wizard is a wizard to create a new *.zul file easily.
zk.xml Editor: It helps you to edit zk.xml, the configuration file of ZK Ajax Framework
Prerequisite
There are three softwares you need to download and install prior to use ZK Studio:
JDK 6:
http://java.sun.com/javase/downloads/index.jsp
JDK 5:
http://java.sun.com/javase/downloads/index_jdk5.jsp
Installation Instructions:
http://java.sun.com/javase/6/webnotes/install/index.html
http://java.sun.com/j2se/1.5.0/install.html
Because ZK-Studio is an Eclipse Plug-in, so you must install Eclipse. We recommend to use the
Eclipse IDE for Java EE Developers package. currently Eclipse v3.3 (Europa)
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/europawinter
and v3.4(Ganymede)
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/ganymedesr1
are supported.
Install:
Extract the "eclipse" folder from downloaded zip file to a proper location. To make sure Eclipse
IDE can be run in your system, execute the eclipse.exe (in windows environment) or eclipse
(in *nix environment) in that eclipse folder to start up the Eclipse IDE.
Tips:
We recommend to modify some parameters in the configuration file eclipse.ini to gain
performance, please refer to http://www.eclipsezone.com/eclipse/forums/t61618.html and
http://blog.xam.dk/archives/68-Eclipse-and-memory-settings.html
Application Servers
Before developing web applications in Java with ZK Ajax Framework, you have to install a
application server. Apache Tomcat is one of the most popular Web containers, download it at
http://tomcat.apache.org/ , both v5.5 and v6.x are supported.
Install:
Download the zip file of Tomcat distribution, extract it to a proper location (with no illegal
characters or space in the path). We will have to config it with Eclipse IDE in “Running the ZUL
File” section.
Tips:
If you are not only want to develop Web Applications, but also need to deploy them on Apache
Tomcat; Here's the official installation instructions for directly running Apache Tomcat in your
environment:
v6.x:
http://tomcat.apache.org/tomcat-6.0-doc/setup.html
v5.5:
http://tomcat.apache.org/tomcat-5.5-doc/setup.html
Install ZK Studio
Since ZK Studio is an Eclipse plugin, we recommend to install ZK Studio via Eclipse Update
Manager. It provides a better installation experience and online update mechanism for
maintain our release.
Download ZK Library:
You have to download the ZK binary distribution in order to run or develop the ZK Web
Application, please download the last one in "ZK Recommended Releases" section in http://
www.zkoss.org/download/zk.dsp and save it to a proper location. You can also extract the
content, but it is not necessary.
Configure ZK Library:
1.Start the Eclipse which already has ZK Studio installed.
4.On the right panel of the ZK Packages preference page in Preferences Window, select
Add Directory if you have extract the ZK Library zip file, point the location to the
extracted file folder, then click OK; Otherwise select Add File if you didn't had extract
the zip file, then select the ZK Package zip file.
6.Type the alias name as you like for this imported package on next window, click OK.
In ZK Packages preferences page, you can check the check box of the imported ZK Packages
on the ZK Package list as the default ZK library for any ZK Web application you will create
later. If you don't select anyone as a default ZK library, ZK Studio will automatically choose the
latest version of those imported ZK Packages.
Eclipse 3.3:
6.On the next page you can choose which ZK packages you want to use for this Dynamic Web
Project. It will automatically choose the default ZK packages configured in the ZK Packages
preferences page in Preferences Window of Eclipse.
You can select other ZK packages installed in Eclipse by click the combo box.
7.Click Finish, the New Project Wizard will setup a Dynamic Web Project ready for
development.
Eclipse 3.4:
5.If you don't want to modify the default directory of Context Root, Content Directory, Java
Source Directory, just click Next.
6.On the next page you can choose which ZK packages you want to use for this Dynamic Web
Project. It will automatically choose the default ZK packages configured in the ZK Packages
preferences page in Preferences Window of Eclipse.
7.Click Finish, the New Project Wizard will setup a Dynamic Web Project ready for
development.
Tips:
You can see a ZK mark on the project's right top icon to indicate that this project is support
ZK:
You can create new ZUL file via [File]/[New]/[File] command in Eclipse main menu.
(1)Right click on the opened project which has been created as Dynamic Web Project in
"Project Explorer" view or "Package Explorer" view, select [New]/[ZUL].
2.Type the file name you want in File name textbox, select the options your want in the
beneath check box.
(you can refer to developer's guide for the meaning of these instructions:
http://www.zkoss.org/doc/devguide-single/index.html#id457941
http://www.zkoss.org/doc/devref-single/index.html#id385772 ), click Finish.
If you create the project without selecting the ZK Supports facet during the New Dynamic
Web Project Wizard, you have to set that project install the ZK Supports facet to support ZK
Ajax Framework. Right click the project root node icon and select Properties. On the pop-up
project preference window, select Project Facets on left part, select the ZK Support on right
panel, click Apply, then click OK to close project preference window.
For Eclipse Java Project which is only a Java Project, you can still have New ZUL File Wizard
(but the context menu option only available in Package Explorer & Navigator view in Eclipse )&
Hierarchy View of Web Page, Property View of UI Tag, Ajax Widget Palette. But if you want to
preview zul file with Visual Editor, you need to do some extra configuration, refer to ZUL Visual
Editor section for more detail.
ZUL Editor
ZUL Editor is an intelligent text editor design for authoring *.zul & *.zhtml file, when you
double click the zul file or zhtml file in Navigator View, Package Explorer View, Project Explorer
View, the file will be opened in ZUL Editor automatically. It provides Syntax Coloring, Syntax
Check, Mark Occurrence, Content Assistance, JAVA Doc Hovering, Hyperlink
Navigation, ZUL file formatting.
<zscript><![CDATA[
System.out.println("Hello World!");
]]></zscript>
<button label="SayHello">
<attribute name="onClick">
<![CDATA[
alert("Hello World!");
]]>
</attribute>
</button>
With th add of surrounding <![CDATA[ ]]> in zscript, ZK Studio can provide powerful
Content Assist and the code inside the <![CDATA[ ]]> will be syntax colored as Java
code.
3.When import package in zscript, use //@IMPORT comment, and separate import section with
other zscript code by <![CDATA ]]>:
<zscript>
<![CDATA[
//@IMPORT
import java.io.*;
4.When you declare method in zscript, use //@DECLARATION comment, and separate method
declaration section with other zscript code by <![CDATA ]]>:
<zscript>
<![CDATA[
//@DECLARATION
void sayHello1() {
alert("Hello World 1!");
}
void sayHello2() {
alert("Hello World 2!");
}
]]>
<![CDATA[
sayHello1();
sayHello2();
]]></zscript>
Mark Occurrence:
Mark Occurrence is a useful functionality when you need to trace certain variable or component
accessing activities in code. It can show the variable both inside and outside zscript.
Move the cursor to a certain variable, object, method or class declaration, all the
correspondingtokens (read/write access) in currently opened zul will be marked.
Syntax Check
The indicators on the right side vertical ruler can help you quickly find out how many error and
where the error is in current zul file, click the marker on it can jump to the line which has
grammar error.
Move the mouse to the error occur position (marked with red or yellow wavy line), the error
message will be shown in tooltip.
ZUML & XML tag support content assist, you can invoke it by default Content Assist keyboard
shortcut.
Zscript Content Assist can let you coding Zscript code rapidly, it can provide you auto-complete
function in <zscript>...</zscript>, <attribute name='onXXX'>...</attribute> code
block and event attribute value in the ZUML tag.
The class that is located in JAR file also can be content-assisted, and if you had set the
associated source for that JAR file, the Java Doc can be shown aside the candidate list (For
how to set source for a certain JAR file, refer to B-2 Add Source Code and Javadoc Resource to
JAR File).
Inside the EL Expression you can also invoke the Content Assist by keyboard shortcut.
The content in use & apply attribute also support Content Assist.
The default keyboard shortcut for Content Assist in English Version of Eclipse is "Ctrl + Space",
you can change the keyboard shortcut in Preference Window, please refer to B-1 Config
keyboard shortcuts for detail.
For easily understanding the source code, ZK Studio support the JAVA Doc hovering. When
move the mouse pointer on the code and stand for a while, the JAVA Doc belong to the
element that is under the mouse pointer will be shown in tooltip.
You need to set source or JAVA Doc for some JAR files if they don't contain source inside, refer
to B-2 Add Source Code and Javadoc Resource to JAR File for how to do it.
Hyperlink Navigation
Hyperlink Navigation let you easily navigate through project resource, you can invoke it by:
1.Move cursor to a certain element belongs to the content of ZUL Editor and press F3.
URL Hyperlink
All elements in ZUL Editor that presents an URL are able to use Hyperlink Navigation.
If a literal string in zul file opened by ZUL Editor is a relative path to certain resource in this
project's WebContent folder, it can be access though Hyperlink Navigation.
In ZUL Editor, you can navigate to the Java class specified in use="ClassName" &
apply="ClassName" attribute by Hyperlink Navigation.
(You have to set source for that class if the class is in a JAR File that doesn't had set source,
refer to B-2 Add Source Code and Javadoc Resource to JAR File for how to do it.)
You can use hyperlinking functionality just as Java Editor in Eclipse in <zscript>...</zscript>
and <attribute name = "onXXX">...</attribute> code block which use the default JAVA
language.
For event attribute of ZUML tag, the content Java code in that attribute value is accessible by
Hyperlink Navigation.
ZUL Editor support zul file source formatting function, in the current opened zul editor, right
click and select the Format option, the source code will be formatted as standard xml file, but
the code content in <zscript>...</zscript> and <attribute name =
"onEventName">...</attribute> will be preserved.
Also you can use keyboard shortcut to accomplish this task, the default source format
keyboard shortcut is Ctrl + Shift + F, you can config the keyboard shortcut as described in B-1
Config keyboard shortcuts.
ZUL Visual Editor provides a WYSIWYG result preview of the currently edited zul file in ZUL
Editor, it can be opened by clicking [Window]/[Show View]/[Others], select ZK > ZUL
Visual Editor.
WYSIWYG Development
ZUL Visual Editor display the result preview of the ZUL document, the preview will be updated
instantly according to the changes of the content of ZUL file in ZUL Editor. When you select
certain component in Intelligent Editor, that whole area of that component inside the ZUL
Visual Editor will be marked with blue dash-line rectangle frame, and if that component has an
id attribute, there will be a ID tag shown in the visualized content area for indication.
There are two control buttons on ZUL Visual Editor, right one is to refresh the content shown in
ZUL Visual Editor, right one is to refresh preview if the ZUL Visual Editor doesn't change the
preview when you update zul file, left one is used to completely restart ZUL Visual Editor when
you manually change your JAR file in project's library.
If you click certain component in the result preview of the ZUL Visual Editor, the
corresponding code segment in ZUL Editor and the component in Hierarchy View of Web Page
will be highlighted.
ZUL Visual Editor can present the preview of your zul file even if they are in a Java Project that
is not a Dynamic Project. You have to set a folder as the WebContent path in project
preference and make sure at least one ZK Package has been installed in Eclipse.
Ajax Widget Palette Provides a Drag & Drop component palette toolbox for ZUL File, you can
open it by clicking [Window]/[Show View]/[Others], select ZK > ZUL Palette.
Name Filtering
The Ajax Widget Palette support ZUML tag name filtering, you can type the component name
in the top Filter text box to search for a component, the candidate lists of components will
show out.
Each component in this tree structure has a special icon to distinguish different tag elements.
Any modify on the zul file will update the tree content in Hierarchy View of Web Page
immediately. You can also modify the file content by using mouse dragging node inside the
Hierarchy View of Web Page or using right-click menu.
When selecting a tag in ZUL Editor or a node in Hierarchy View of Web Page, the associated
attribute information of the selected tag will show in it. For some properties which are
enumerations (ex: true/false, normal/none, left/center/right), an informative combo box
editor is used to help you input the correct value.
The zk.xml Editor helps you to edit the configuration file (the zk.xml inside your project's WEB-
INF folder) of ZK Ajax Framework, it can be opened by right click the zk.xml and select [Open
With]/[XML Editor for zk.xml] in context menu.
zk.xml Editor provides the content assistance functionality in editing the zk.xml configuration
file, for detail description of every element in zk.xml, please refer to ZK Developer's
Reference:
http://www.zkoss.org/doc/devref/ch07.html
Global Preference
Services
Error Reporter
ZK Studio can upload it's error log to Potix to improve the quality and performance for future
version of ZK Studio. check this to enable error log functionality.
Visual Editor
This page is to config some presentation style of Visual Editor.
ZK Packages
All the installed ZK Package in Eclipse will be listed here, you can select default ZK Package for
used in creating new Dynamic Web Project. You can also add/remove installed packages in this
page.
In the Project Explorer, Package Explorer, Navigator view of Eclipse, select Dynamic Web
Project or Pure Java Project, right click and select Properties, according to the kind of project
you selected, there will be different preference pages.
ZK
This preference page list the version number, library location, and the included add-on library
list of the currently used ZK package for this project.
The Refresh ZK Library button is used to refresh the above add-on library list in case of add-
on library jar files in this project were out of sync.
Package Setting
Visual Editor
This preference page config the ZK library that used to generate preview result in Visual Editor
This option is to config which ZK library that used to generate preview result in Visual Editor,
select Use WEB-INF / lib to use the ZK library configured for this project; Select Use ZKs to
use the ZK Packages installed in Eclipse which are listed in Global Preference.
ZUL Editor
This preference page list some option you can turn on/off to improve the performance of ZUL
Editor.
Check this option will enable mark occurrence feature in ZUL Editor. Turn this off to get some
performance boost.
Check this option will enable syntax check feature in ZUL Editor. Turn this off to get some
performance boost.
Enable hyperlinking
Check this option will enable Hyperlinking Navigation feature in ZUL Editor. Turn this off can
get some performance boost.
It lacks the Package Setting preference page, to enable that page, you must install ZK
Supports Facet in Project Facets page in this project's preference window, refer to Import ZK
to an exist 'Dynamic Web Project section for detail.
Visual Editor
This preference page config the ZK library that used to generate preview result in Visual Editor
Startup Library
This option is to config which ZK library that used to generate preview result in Visual Editor,
select Use WEB-INF / lib to use the ZK library configured for this project; Select Use ZKs to
use the ZK Packages installed in Eclipse which are listed in Global Preference.
ZUL Editor
This preference page list some option you can turn on/off to improve the performance of ZUL
Editor
Enable hyperlinking
Check this option will enable Hyperlinking Navigation feature in ZUL Editor. Turn this off can
get some performance boost.
It lacks the Package Setting preference page, to enable that page, you have to use Dynamic
Web Project instead of pure Java project.
This preference page config the ZK library that used to generate preview result in Visual Editor.
Startup Library
This option is to config which ZK library that used to generate preview result in Visual Editor,
select Use WEB-INF / lib to use the ZK library configured for this project; Because this is a
pure Java Project, only the ZK Packages installed in Eclipse are applicable.
WEB Content
Config which folder to be the WebContent folder for this project.
Tips:
the WebContent folder is the folder which contains the file you need to deploy to server for this
Web application.
ZUL Editor
This preference page list some option you can turn on/off to improve the performance of ZUL
Editor.
Enable hyperlinking
Check this option will enable Hyperlinking Navigation feature in ZUL Editor. Turn this off can
get some performance boost.
Usage Issue
1.Q:Why I can't see the Syntax Colored zscript code in my zul page?
A:You have to insert <![CDATA[ and ]]> inside the <zscript> and <attribute> code block.
2.Q:I have installed the ZK Studio plugin in my Eclipse. When I open a zul file by double
clicking the entry in Project Explorer in Eclipse, it is not opened by the Intelligent ZUL Editor
3.Q:Why I always got JAVA Syntax Error mark in my code, even if it can run correctly on ZK?
A:Currently you have to append two special comments: //@DECLARATION and //@IMPORT in
zscript code block inside the <zscript>. The //@DECLARATION is used when declaring classes
and functions; the //@IMPORT is used when there is a JAVA import directive; these two
comments can only be used only once in one code section surrounded with <![CDATA[ ]]>.
And if you define a class in zscript, don't use the access modifier public, just use the default
access modifier.
4.Q:I use the non-JAVA Syntax such as var zoom = self.zoom in my code. Why the ZUL
Editor shows me that the code is wrong?
A:Currently Syntax Check is for JAVA only, so the code like var zoom = self.zoom will be
highlighted as warning in ZUL Editor.
Many keyboard shortcuts are configurable via Preference Window (click [Windows]/
[Preferences] in Eclipse main menu), the preference page to configure keyboard shortcuts
(or so called "hotkey") is located in General/Keys preference page.
You can attach a source archive (another JAR file which include the source code) or source
folder to this library. Eclipse will then use this resource to show the source instead of a the
decompiled code. Setting the source attachment also allows source level stepping with the
debugger.
The source JAR files of ZK Package is under the dist/src folder in the already extracted ZK
package.
Uninstallation