Get Spreadsheet Running Quickly in JSF"

From Documentation
(Created page with "{{ZKSpreadsheetEssentials3PageHeader}} {{ZSS EE}}")
 
(copy from JSPs)
Line 3: Line 3:
  
  
 +
 +
__TOC__
  
 
{{ZSS EE}}
 
{{ZSS EE}}
 +
 +
= Download ZSS JSF Example Project =
 +
If you want to run ZK spreadsheet JSF demo in your local site, just [http:// download the example project WAR file] and deploy to your application server.
 +
 +
 +
= Create and Run a JSF Project =
 +
 +
The following sections tell you how to prepare an environment for working with Spreadsheet in JSF.
 +
 +
== Prerequisites ==
 +
 +
Before developing a web application with Spreadsheet, you should prepare the following softwares:
 +
* Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html JDK] 1.5 or above
 +
* Install an application server
 +
** You can install any JavaEE application server you like. If you don't have one, [http://tomcat.apache.org Tomcat] is a good choice.
 +
* Install a development tool.
 +
**  In this book, we will use [http://www.eclipse.org/downloads Eclipse]  as the default IDE to explain related setup.
 +
 +
== Prepare a Project ==
 +
 +
To develop a web application in Eclipse, you could use a '''dynamic web project''' or a '''maven project'''. We will describe steps to create these two kind of project respectively.
 +
 +
 +
=== Steps to Prepare an Eclipse Dynamic Web Project ===
 +
 +
The steps to create a project from scratch:
 +
# Create a dynamic web project
 +
# Install JSF
 +
## [http://javaserverfaces.java.net/download.html Download JSF Reference Implementation].
 +
# Install Spreadsheet library
 +
## Download ZK Spreadsheet component (binary). Choose [http://www.zkoss.org/download/zkspreadsheet "Free Evaluation Downloads" from product page] or licensed  EE from [http://www.zkoss.org/download/premium premium download].
 +
##:
 +
## Extract the zip and copy those JAR files under '''<tt>/dist/lib</tt>''' and '''<tt>/dist/lib/ext</tt>''' to '''<tt>/WEB-INF/lib</tt>''' under your web project's root folder.
 +
##: Make sure '''zssjsp.jar''' existed under  <tt>/WEB-INF/lib</tt>.
 +
# Set up web.xml
 +
#: Please refer to [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml|Sample of web.xml]] and  [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml_for_Servlet_2.3| Sample of web.xml for Servlet 2.3]] ''(For some web container which support Servlet 2.3 only (e.g. Tomcat 4.x)''
 +
 +
=== Steps to Prepare a Maven Project ===
 +
You can download [http:// download our sample Maven project] to save your time. If you have to create from scratch, please follow the instructions below.
 +
 +
:1. Create a Maven project.
 +
:: You should set packaging to '''war'''.
 +
:: We recommend you to [[ZK_Installation_Guide/Quick_Start/Create_and_Run_Your_First_ZK_Application_with_Eclipse_and_Maven#Create_a_.22Hello_World.22_application_with_ZK_Maven_Archetype| create a project from an archetype]], then you can skip step 3.
 +
 +
:2. Setup Maven dependency.
 +
::First, you should [[ZK_Installation_Guide/Setting_up_IDE/Maven/Use_ZK_Maven_Artifacts/Resolving ZK Framework Artifacts via Maven#Add_to_your_Maven_projects | 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:
 +
<source lang='xml'>
 +
<dependency>
 +
<groupId>com.sun.faces</groupId>
 +
<artifactId>jsf-api</artifactId>
 +
<version>${jsf-api.version}</version>
 +
<scope>compile</scope>
 +
</dependency>
 +
<dependency>
 +
<groupId>com.sun.faces</groupId>
 +
<artifactId>jsf-impl</artifactId>
 +
<version>${jsf-api.version}</version>
 +
<scope>compile</scope>
 +
</dependency>
 +
 +
<dependency>
 +
<groupId>org.zkoss.zk</groupId>
 +
<artifactId>zkmax</artifactId>
 +
<version>${zk.version}</version>
 +
</dependency>
 +
<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>
 +
 +
</source>
 +
 +
* If <tt>${zss.version}</tt> is 3.0.0 or above, <tt>${zk.version}</tt> should be 6.5.2.
 +
 +
You can reference the pom.xml in our example project to verify your own pom.xml.
 +
 +
: 3. Set up web.xml.
 +
:: Please refer to [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml|Sample of web.xml]] and  [[ZK_Installation_Guide/ZK_Background/Sample_of_web.xml_for_Servlet_2.3| Sample of web.xml for Servlet 2.3]] ''(For some web container which support Servlet 2.3 only (e.g. Tomcat 4.x)''
 +
 +
 +
== 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 <tt>index.jsp</tt> with content below:
 +
<source lang='xml' high=''>
 +
 +
</source>
 +
* 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 <tt>index.jsp</tt> to see if you can see the Spreadsheet.

Revision as of 03:25, 1 August 2013


Get Spreadsheet Running Quickly in JSF





Available in ZK Spreadsheet EE only

Download ZSS JSF Example Project

If you want to run ZK spreadsheet JSF demo in your local site, just [http:// download the example project WAR file] and deploy to your application server.


Create and Run a JSF Project

The following sections tell you how to prepare an environment for working with Spreadsheet in JSF.

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

To develop a web application in Eclipse, you could use a dynamic web project or a maven project. We will describe steps to create these two kind of project respectively.


Steps to Prepare an Eclipse Dynamic Web Project

The steps to create a project from scratch:

  1. Create a dynamic web project
  2. Install JSF
    1. Download JSF Reference Implementation.
  3. Install Spreadsheet library
    1. Download ZK Spreadsheet component (binary). Choose "Free Evaluation Downloads" from product page or licensed EE from premium download.
    2. 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.
  4. Set up web.xml
    Please refer to Sample of web.xml and Sample of web.xml for Servlet 2.3 (For some web container which support Servlet 2.3 only (e.g. Tomcat 4.x)

Steps to Prepare a Maven Project

You can download [http:// download our sample Maven project] to save your time. If you have to create from scratch, please follow the instructions below.

1. Create a Maven project.
You should set packaging to war.
We recommend you to create a project from an archetype, then you can skip step 3.
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>com.sun.faces</groupId>
			<artifactId>jsf-api</artifactId>
			<version>${jsf-api.version}</version>
			<scope>compile</scope>
		</dependency> 
		<dependency>
			<groupId>com.sun.faces</groupId>
			<artifactId>jsf-impl</artifactId>
			<version>${jsf-api.version}</version>
			<scope>compile</scope>
		</dependency>

		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkmax</artifactId>
			<version>${zk.version}</version>
		</dependency>
		<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, ${zk.version} should be 6.5.2.

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 and Sample of web.xml for Servlet 2.3 (For some web container which support Servlet 2.3 only (e.g. Tomcat 4.x)


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:

  1. Create a simple Excel file or use the sample file in our example project. Put the file under your web application's root folder.
  2. Create index.jsp with content below:
  • 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.