23.12.2012 Views

ZK Developer's Guide

ZK Developer's Guide

ZK Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

[ 9 ]<br />

Chapter 1<br />

First Step: Say Hello to <strong>ZK</strong><br />

To get a feel of working with <strong>ZK</strong>, it's wise to do a small example. To follow the long<br />

tradition of many programming technologies, we will start with the traditional<br />

"Hello World" example.<br />

For the examples, we are using version 2.3.0 of the <strong>ZK</strong> framework.<br />

The best way to start with <strong>ZK</strong> is to download the zkdemo application from the<br />

<strong>ZK</strong> team. The application can be downloaded from: http://www.zkoss.org/<br />

download/. The application comes in a ZIP archive. This archive contains four files:<br />

1. zkdemo-all.war<br />

2. zkdemo.war<br />

3. zkdemos-all.ear<br />

4. zkdemos.ear<br />

The WAR files are for deploying inside a J2EE web container. The EAR files are<br />

for deploying inside a J2EE application server. To start, just throw the zkdemo.<br />

war inside the webapps directory of Tomcat. After this the application is available<br />

with the URL http://localhost:8080/zkdemo (if Tomcat runs at port 8080). Now<br />

create a new file with the name hello.zul, and copy this page to the decompressed<br />

application zkdemo. The page can be accessed with http://localhost:8080/<br />

zkdemo/hello.zul.<br />

<br />

Hello World!<br />

<br />

The downloaded archive of the demo contains zkdemo.war,<br />

zkdemo-all.war, zkdemos-all.ear, and zkdemos.ear. The<br />

files without the suffix -all does not contain a complete application.<br />

The libraries from <strong>ZK</strong> are missing. For a first start you can copy the<br />

zkdemo-all.war to your Tomcat webapps directory. If you want<br />

to use the zkdemo.war please copy all libraries from your zk-2.3.0<br />

(directory zk-2.3.0/dist/lib) into the expanded directory of the<br />

web application. Without a copy of the libraries you get an error while<br />

executing your application.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!