Get Spreadsheet Running Quickly in JSP"
Line 39: | Line 39: | ||
##: Make sure '''zssjsp.jar''' existed under <tt>/WEB-INF/lib</tt>. | ##: Make sure '''zssjsp.jar''' existed under <tt>/WEB-INF/lib</tt>. | ||
# Set up web.xml | # Set up web.xml | ||
− | #: Please refer to [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml|Sample of web.xml]] | + | #: Please refer to [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml|Sample of web.xml]]. |
=== Steps to Prepare a Maven Project === | === Steps to Prepare a Maven Project === | ||
Line 45: | Line 45: | ||
:1. Create a Maven project. | :1. Create a Maven project. | ||
:: You should set packaging to '''war'''. | :: You should set packaging to '''war'''. | ||
− | |||
:2. Setup Maven dependency. | :2. Setup Maven dependency. | ||
Line 54: | Line 53: | ||
<source lang='xml'> | <source lang='xml'> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
<dependency> | <dependency> | ||
<groupId>org.zkoss.zss</groupId> | <groupId>org.zkoss.zss</groupId> | ||
Line 72: | Line 66: | ||
</source> | </source> | ||
− | * If <tt>${zss.version}</tt> is 3.0.0 or above | + | * If <tt>${zss.version}</tt> is 3.0.0 or above. |
You can reference the pom.xml in our example project to verify your own pom.xml. | You can reference the pom.xml in our example project to verify your own pom.xml. | ||
: 3. Set up web.xml. | : 3. Set up web.xml. | ||
− | :: Please refer to [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml|Sample of web.xml]] | + | :: Please refer to [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml|Sample of web.xml]]. |
== Verify Your Project == | == Verify Your Project == |
Revision as of 07:29, 7 August 2013
Available in ZK Spreadsheet EE only
Download ZSS JSP Example Project
If you want to run ZK spreadsheet JSP demo in your local site, just [http:// download the example project WAR file] and deploy to your application server.
Create and Run a JSP Project
The following sections tell you how to prepare an environment for working with Spreadsheet in JSP.
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 a development tool.
- In this book, we will use Eclipse as the default IDE to explain related setup.
Prepare a Project
Steps to Prepare an Eclipse 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.
If you have to create a project by your own, you can follow the steps below:
- Create a dynamic web project
- Install Spreadsheet library
- Download ZK Spreadsheet component (binary). Choose "Free Evaluation Downloads" from product page or licensed EE from premium download.
- Extract the zip and copy those JAR files under /dist/lib and /dist/lib/ext to /WEB-INF/lib under your web project's root folder.
- Make sure zssjsp.jar existed under /WEB-INF/lib.
- Download ZK Spreadsheet component (binary). Choose "Free Evaluation Downloads" from product page or licensed EE from premium download.
- Set up web.xml
- Please refer to Sample of web.xml.
Steps to Prepare a Maven Project
- 1. Create a Maven project.
- You should set packaging to war.
- 2. Setup Maven dependency.
- First, you should setup zk maven repository. Notice that different edition has a different repository, and licensed products even require authentication.
- Because this feature is only available in EE, you should add following dependencies:
<dependency>
<groupId>org.zkoss.zss</groupId>
<artifactId>zssex</artifactId>
<version>${zss.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zss</groupId>
<artifactId>zssjsp</artifactId>
<version>${zss.version}</version>
</dependency>
- If ${zss.version} is 3.0.0 or above.
You can reference the pom.xml in our example project to verify your own pom.xml.
- 3. Set up web.xml.
- Please refer to Sample of web.xml.
Verify Your Project
After completing above steps, preparation for working with Spreadsheet and JSP is done. You can use a simple page to verify your preparation. Steps are as follows:
- Create a simple Excel file or use the sample file in our example project. Put the file under your web application's root folder.
- Create index.jsp with content below:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My First ZK Spreadsheet JSP application</title>
<zssjsp:head/>
</head>
<body>
<%@ taglib prefix="zssjsp" uri="http://www.zkoss.org/jsp/zss"%>
<div width="100%" style="height: 100%;">
<zssjsp:spreadsheet
id="myzss" src="/WEB-INF/hellozss.xlsx" width="100%"
height="100%" maxVisibleRows="200" maxVisibleColumns="40" showSheetbar="true"/>
</div>
</body>
</html>
- Line 8: The head tag generates ZK required JS and CSS.
- Line 11: Declare a taglib before using Spreadsheet JSP tag is necessary.
- Line 13: Use spreadsheet JSP tag with prefix you specified previously.
Now, deploy the project to your application server and visit index.jsp to see if you can see the Spreadsheet.