Setting Up Environment
The purpose of this section is to tell you how to prepare an environment for working with Spreadsheet in API.
Prerequisites
Before developing a web application with Spreadsheet, you should prepare the following softwares:
- Install JDK 1.5 or above
- Install an application server
- You can install any JavaEE application server you like. If you don't have one, Tomcat is a good choice.
- Install Eclipse or other development tool.
- In this book, we will use Eclipse as the default IDE to explain related setup.
Prepare a Dynamic Web Project
To save your time from creating a project out of nothing, you could just download the sample project which is a ready-to-run Eclipse dynamic web project. Even if you insist to create a project by your own, you still can reference the sample project.
There are several files inside the sample project that require to explain:
- /WEB-INF/web.xml
This web descriptor contains minimum configuration to run Spreadsheet.
- /WEB-INF/lib
All jar files required to run Spreadsheet are here. You should see zss.jar in it.
- /index.zul
The page that uses Spreadsheet, and you can learn the basic usage and configuration.
<window title="My First ZK Spreadsheet Application" apply="org.zkoss.zss.essential.MyComposer"
border="normal" vflex="1" width="100%">
<spreadsheet src="/WEB-INF/book/startzss.xlsx" vflex="1" width="100%"
maxVisibleRows="150" maxVisibleColumns="40"
showToolbar="true" showSheetbar="true" showFormulabar="true"/>
</window>
- Line 1: We assign a controller in apply attribute to control Window and its child component.
- org.zkoss.zss.example.startzss.MyComposer.java
This class is a controller where we can write codes to control Spreadsheet e.g. listening Spreadsheet's events, or get an object of Spreadsheet. For complete explanation, please refer to ZK Developer's Reference/MVC/Controller/Composer
Prepare a Maven Project
If you want to create a Maven project, you can [http:// download our sample Maven project] to avoid creating from scratch.
If you use Compact Edition (CE) The main dependency in the sample project is org.zkoss.zss:zss:
<dependency>
<groupId>org.zkoss.zss</groupId>
<artifactId>zss</artifactId>
<version>${zss.version}</version>
</dependency>
- ${zss.version} can be 3.0.0 or above.
If you want to use Enterprise Edition (EE), you should replace org.zkoss.zss:zss with org.zkoss.zss:zssex and add org.zkoss.zk:zkmax.
<dependency>
<groupId>org.zkoss.zss</groupId>
<artifactId>zssex</artifactId>
<version>${zss.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkmax</artifactId>
<version>${zk.version}</version>
</dependency>
- If ${zss.version} is 3.0.0 or above, ${zk.version} should be 6.5.2.
Except there is no JAR under /WEB-INF/lib, the rest are the same as dynamic web project. Please read previous paragraph about explanation of web.xml, index.zul and MyComposer.java.