Professional Documents
Culture Documents
For ZK 6.5.0
PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Thu, 13 Sep 2012 11:30:10 CST
Contents
Articles
ZK Installation Guide Before You Start New to Java New to Java Servlet Quick Start Create and Run Your First ZK Application with Eclipse and ZK Studio Create and Run Your First ZK Application with Eclipse and Maven Create and Run Your First ZK Application with NetBeans and REM Create and Run Your First ZK Application Manually ZK Background Sample of web.xml for Servlet 3.0 Sample of web.xml for Servlet 2.4 Sample of web.xml for Servlet 2.3 The Content of ZK Binary Distribution Setting up Servers Tomcat JBoss JBoss Cluster WebSphere WebSphere Portal Oracle Server WebLogic WebLogic Portal WebLogic Cluster Google App Engine Heroku Red Hat OpenShift Express Liferay Pluto Jetty Resin Setting up OSGi EclipseRT Web Starter Kits Setting up OS 1 1 1 2 3 3 8 17 21 23 23 24 26 27 29 30 31 32 33 37 40 41 42 47 48 52 57 60 84 87 87 88 88 93
Linux IOS Setting up IDE Eclipse with ZK Studio Eclipse without ZK Studio Maven Setting up Maven on Eclipse Resolving ZK Framework Artifacts via Maven XML Editor
93 94 95 95 96 98 99 101 108
References
Article Sources and Contributors Image Sources, Licenses and Contributors 109 111
ZK Installation Guide
ZK Installation Guide
Documentation:Books/ZK_Installation_Guide ZK_Installation_Guide</comment> <comment>http:/ / books. zkoss. org/ wiki/
New to Java
You don't need to know Java to use ZK, since all rich user interfaces can be implemented in a HTML-like markup language called ZUML. However, to complete a Web application, you or your teammates need to write some Java code to glue UI and services together. It requires some Java knowledge. If you haven't installed the following applications on your computer, please download and install them first. Java SE Development Kit (JDK) JDK is a software development for writing application in Java. Note : we suggest you install this first even some web server already contains one Web Server A Web servlet is used to host the Web application you developed ZK Framework ZK is an Ajax framework simplifying the development of Web applications
Java Tutorials
Here are some good Java tutorials.
Java Language Basic URLs [1] [1]
New to Java
Version History
Version Date Content
Version History
Version Date Content
References
[1] [2] [3] [4] http:/ / richjava. wordpress. com/ http:/ / en. wikipedia. org/ wiki/ Web_container http:/ / www. google. com. tw/ search?q=define:Java+ Servlet http:/ / tomcat. apache. org/
Quick Start
This chapter describes how to quickly start your first ZK application.
Create and Run Your First ZK Application with Eclipse and ZK Studio
ZK Studio [1] is an Eclipse plugin to simplify the development of ZK applications with Eclipse. If you prefer to install it manually or use with other IDE, please refer to Create and Run Your First ZK Application Manually.
Prepare Eclipse
Install Eclipse
1. Visit Eclipse download page [2] and download Eclipse IDE for Java EE Developers [3] 2. Uncompress it to a proper directory 3. Then, eclipse is ready to start for use. For example, you could double-click eclipse.exe to start Eclipse under Windows.
Prerequisites
You can follow ZK Studio Installation Guide before installing ZK Studio: Java SE Development Kit (JDK) Java SE Development Kit version 5 or 6 is required in order to run Eclipse, you can download either of them from the links below: JDK 6 http://java.sun.com/javase/downloads/index.jsp [5] JDK 5 http://java.sun.com/javase/downloads/index_jdk5.jsp [6]
[4]
Create and Run Your First ZK Application with Eclipse and ZK Studio For detailed information on JDK installation, please see http:/ / java. sun. com/ javase/ 6/ webnotes/ install/ index. html [7], or http://java.sun.com/j2se/1.5.0/install.html [8] Eclipse IDE for Java EE Developers ZK Studio is an Eclipse Plug-in so you must install Eclipse in advance. The following Eclipse IDE for Java EE Developers packages are recommended: Eclipse v3.6 (Helios) http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliossr1 [9] Eclipse v3.5 (Galileo) http://www.eclipse.org/downloads/packages/release/galileo/sr2 [10] Please also see WTP Tutorials Building and Running a Web Application [11] for details. Application Servers Before developing web applications in Java with the ZK Ajax Framework, you need to install an application server. Apache Tomcat is one of the most popular Web containers. Tomcat versions 6 and 7 are compatible with ZK Studio and can be downloaded from the link http://tomcat.apache.org/ [4]. Download the zip file of Tomcat distribution and extract it into a proper location (with no illegal characters or space in the pathname). Tomcat requires configuration before it works with Eclipse, please see ZK Studio Essentials for details.
Installing ZK Studio
Please follow the installation guide for your Eclipse version: Eclipse v3.6 (Helios) Installation Guide for Eclipse v3.6 (Helios) Eclipse 3.5 (Galileo) Installation Guide for Eclipse 3.5 (Galileo) Eclipse 3.4 (Ganymede) Installation Guide for Eclipse 3.4 (Ganymede) Eclipse 3.3 (Europa) Installation Guide for Eclipse 3.3 (Europa)
Create and Run Your First ZK Application with Eclipse and ZK Studio 5. Click Finish
Create and Run Your First ZK Application with Eclipse and ZK Studio
3. The newly created ZUL File will be opened in the ZUL Editor.
Create and Run Your First ZK Application with Eclipse and ZK Studio
Version History
Version Date Content
References
[1] http:/ / www. zkoss. org/ product/ zkstudio [2] http:/ / www. eclipse. org/ downloads/ [3] http:/ / www. eclipse. org/ downloads/ download. php?file=/ technology/ epp/ downloads/ release/ ganymede/ SR2/ eclipse-jee-ganymede-SR2-win32. zip [4] http:/ / books. zkoss. org/ wiki/ ZK_Studio_Essentials/ Installation [5] http:/ / java. sun. com/ javase/ downloads/ index. jsp [6] http:/ / java. sun. com/ javase/ downloads/ index_jdk5. jsp [7] http:/ / java. sun. com/ javase/ 6/ webnotes/ install/ index. html
Create and Run Your First ZK Application with Eclipse and ZK Studio
[8] http:/ / java. sun. com/ j2se/ 1. 5. 0/ install. html [9] http:/ / www. eclipse. org/ downloads/ packages/ eclipse-ide-java-ee-developers/ heliossr1 [10] http:/ / www. eclipse. org/ downloads/ packages/ release/ galileo/ sr2 [11] http:/ / www. eclipse. org/ webtools/ community/ tutorials/ BuildJ2EEWebApp/ BuildJ2EEWebApp. html
Create and Run Your First ZK Application with Eclipse and Maven
M2eclipse IDE.
[1]
is the first and most mature of the projects aimed at integrating Apache Maven
[2]
Prepare Eclipse
Install Eclipse
Please follow the installation guide for your Eclipse: Install Eclipse
Install M2eclipse
Please follow the installation guide for your M2eclipse: Install M2eclipse
Create and Run Your First ZK Application with Eclipse and Maven
http:/ / mavensync. zkoss. org/ maven2/ Click Verify and then OK to add the catalog. If the Remote catalog is empty.[3]
[1] http:/ / www. eclipse. org/ m2e/ [2] http:/ / maven. apache. org/ [3] If an error message appears stating that the Remote catalog is empty, this is most likely due to a bug in the m2eclipse plugin in v0.12.x, MNGECLIPSE-2757 (https:/ / issues. sonatype. org/ browse/ MNGECLIPSE-2757). Until m2eclipse 0.13.x or newer versions are released and available, there are two possible workarounds: 1. Install the "older version" 0.10.x from the Installing m2eclipse (http:/ / m2eclipse. sonatype. org/ installing-m2eclipse. html) website. Users will first need to uninstall m2eclipse 0.12.x, restart, and then install 0.10.x available from the following site:
http://m2eclipse.sonatype.org/sites/m2e/0.10.2.20100623-1649/
2. Install the newer version from the following site: http:/ / download. eclipse. org/ technology/ m2e/ releases You first will need to uninstall m2eclipse 0.12.x, restart Eclipse before you can install the newer version from the website above. (Please note: the newer version of M2eclipse plugin is not compatible with the old Maven Project. Therefore you must enable your maven project with the latest M2eclipse plugin from the Installing m2eclipse website.) 3. Create the plugin from the archetype using the Maven command line tool mvn, then use import existing maven project to add the generated project to Eclipse. For more details, please refer to Use the command line version of Maven to create a project.
Create and Run Your First ZK Application with Eclipse and Maven
10
Make sure Create a simple project is unticked in the first screen of the New Maven Project wizard and click Next >.
Create and Run Your First ZK Application with Eclipse and Maven
11
From the Select an Archetype screen, select ZK Maven Archetype from the catalog dropdown list.
Select zk-archetype-webapp from the list. (At the time of writing this is at version 6.0). Next, fill in details for group id, artifact id, version number and package name.
Create and Run Your First ZK Application with Eclipse and Maven
12
If the property zk-version-since is missing.[1] Click Finish and the Eclipse status bar should say ' Creating zk-archetype-webapp ' and ' Updating Maven Dependencies '. If this is the user's first time dealing with ZK libraries, Maven will download the necessary dependencies to compile and run this example, and would be stored in .m2/repository in the user's home directory.
Create and Run Your First ZK Application with Eclipse and Maven
13
[1] Users who are running this wizard for the first time, ZK Archetype would not have been downloaded into m2eclipse yet, and as a result may not populate the zk-version-since property correctly, leading to an error message like the following:
Unable to create project from archetype [org.zkoss:zk-archetype-webapp:6.0 -> http://mavensync.zkoss.org/maven2/], Archetype org.zkoss:zk-archetype-webapp:6.0 is not configured property ''zk-version-since'' is missing. The simple workaround for this problem is to just try again after clicking Finish to end the ZK Maven web project wizard. When re-running the wizard, the zk-version-since property should appear in the list this time.
2. In the goals field, enter jetty:stop jetty:run and tick Skip Tests then click "Apply" then "Run".
Create and Run Your First ZK Application with Eclipse and Maven
14
2. The project will then be packed into a war file and a zip file with source code.
Create and Run Your First ZK Application with Eclipse and Maven In the following example, webapp archetype (number 3) is selected and groupId is set to com.foo, artifactId to mywebapp, version to '0.8.0 and package to com.foo'. $ mvn archetype:generate -DarchetypeCatalog=http://mavensync.zkoss.org/maven2/ [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] -----------------------------------------------------------------------[INFO] Building Maven Default Project [INFO] task-segment: [archetype:generate] (aggregator-style) [INFO] -----------------------------------------------------------------------[INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven. archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: http://mavensync.zkoss.org/maven2/ -> zk-archetype-component (An archetype th at generates a starter ZK component project) 2: http://mavensync.zkoss.org/maven2/ -> zk-archetype-extension (An archetype th at generates a starter ZK extension project) 3: http://mavensync.zkoss.org/maven2/ -> zk-archetype-webapp (An archetype that generates a starter ZK CE webapp project) 4: http://mavensync.zkoss.org/maven2/ -> zk-ee-eval-archetype-webapp (An archety pe that generates a starter ZK EE-eval webapp project) Choose a number: : 3 Define value for property 'groupId': : com.foo Define value for property 'artifactId': : mywebapp Define value for property 'version': 1.0-SNAPSHOT: 0.8.0 Define value for property 'package': com.foo: [INFO] Using property: zk-version-since = 6.0.1 Confirm properties configuration: groupId: com.foo artifactId: mywebapp version: 0.8.0 package: com.foo zk-version-since: 6.0.1 Y: [INFO] -----------------------------------------------------------------------[INFO] BUILD SUCCESSFUL [INFO] -----------------------------------------------------------------------[INFO] Total time: 29 seconds [INFO] Finished at: Fri Jun 22 16:55:27 CST 2012 [INFO] Final Memory: 13M/150M [INFO] ------------------------------------------------------------------------
15
Create and Run Your First ZK Application with Eclipse and Maven
16
After this, the user should now get a new project in the Package explorer.
Create and Run Your First ZK Application with Eclipse and Maven
17
Version History
Version Date Content
Create and Run Your First ZK Application with NetBeans and REM
REM [1] is a NetBeans module for ZK application development contributed by Mr. Sotohiro Terashima.
Create and Run Your First ZK Application with NetBeans and REM 6. Click "Install" and follow the NetBeans plugin manager prompts
18
Create and Run Your First ZK Application with NetBeans and REM 3. Confirm and create a new ZK project.
19
4. Select the ZK project folder, and right click "Run" to deploy the project on Glassfish
Create and Run Your First ZK Application with NetBeans and REM
20
3. Select "ZK505 Demo Project" under "Projects" 4. Select the ZK demo project and right click to select "Run" to deploy the ZK demo
Create and Run Your First ZK Application with NetBeans and REM
21
Version History
Version Date Content
References
[1] http:/ / rem1. sourceforge. net/ [2] http:/ / www. netbeans. org/ downloads/ index. html [3] http:/ / sourceforge. net/ projects/ rem1/ files/
Download ZK Libraries
ZK libraries can be downloaded from ZK Download [3] and then save it to a proper location.
All you need to do is create a web application directory with related files. Now i create one for example named myZK
22
23
Version History
Version Date Content
References
[1] http:/ / tomcat. apache. org [2] http:/ / apache. stu. edu. tw/ / tomcat/ tomcat-6/ v6. 0. 29/ bin/ apache-tomcat-6. 0. 29. exe [3] http:/ / www. zkoss. org/ download/ zk. dsp
ZK Background
This chapter describes the information of ZK installation, such as the sample of web.xml and the content of the binary distribution.
Version History
Version 6.0.0 Date December 2011 Content The support of Servlet 3.0 Pluggability was introduced.
24
25
<servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> --> <servlet> <description>The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> </web-app>
Version History
Version Date Content
References
[1] http:/ / www. zkoss. org/ javadoc/ latest/ zk/ org/ zkoss/ zk/ ui/ http/ DHtmlLayoutServlet. html# [2] http:/ / www. zkoss. org/ javadoc/ latest/ zk/ org/ zkoss/ zk/ au/ http/ DHtmlUpdateServlet. html# [3] http:/ / www. zkoss. org/ javadoc/ latest/ zk/ org/ zkoss/ zk/ ui/ http/ HttpSessionListener. html#
26
Sample of web.xml for Servlet 2.3 </servlet-mapping> --> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> </web-app>
27
Version History
Version Date Content
/doc
This directory holds the documents including release notes and license.
/dist
/dist/lib
This directory holds the ZK libraries
Filename Description License LGPL LGPL LGPL LGPL LGPL LGPL LGPL All All All All All All All All Shipped
zcommon.jar ZK's common library that ZK depends on (org.zkoss.*) zweb.jar zk.jar zul.jar zhtml.jar zkbind.jar zkplus.jar zel.jar zkex.jar ZK's Web library that ZK depends on (org.zkoss.web.* ZK core functions, such as ZK Loader and Update Engine. (org.zkoss.zk.*) ZUL components (org.zkoss.zul.*) ZK HTML (ZHTML) components (org.zkoss.zhtml.*) ZK Bind, including data binding and MVVM. ZK extra utilities integrated easily with other frameworks. (org.zkoss.zkplus.*)
ZK's implementation of EL 2.2. It is based on Apache Tomcat 7's EL 2.2 implementation. Apache ZK professional ZUL components and utilities (org.zkoss.zkex.*)
28
Commercial ZK PE and EE only Commercial ZK EE only
zml.jar zkmax.jar
ZK XML components for generating XML output (org.zkoss.zml.*) ZK enterprise components and utilities (org.zkoss.*)
/dist/lib/zkforge This directory holds the additional components and libraries. It is optional depending on whether you need them. There are three kinds of binary distributions: CE, PE and EE. If not stated explicitly, it is shipped in all distributions.
Filename sapphire.jar silvertail.jar ckez.jar Description Required if you want to use the sapphire theme. Required if you want to use the silvertail theme. Required if you want to use ZK CKeditor component. License Version LGPL LGPL LGPL GPL GPL 6.0.0 6.0.0 3.6.0.1 All All All Shipped
timelinez.jar Required if you want to use ZK Timeline component. timeplotz.jar Required if you want to use ZK Timeplot component. gmapsz.jar zuljsp.jar
Required if you want to use ZK Google Maps component. GPL Required if you want to use ZK JSP Tags. GPL
/dist/lib/ext This directory holds the external libraries required to run ZK. Since these libraries are common, you might have already installed them in your Servlet container. These jar files are optional. You can choose whether to copy depending on your requirements.
Filename commons-fileupload.jar commons-io.jar Description Required if you want to upload files with them. Required if you want to use ZUL's chart component. License Apache Version Commons Fileupload 1.2.2 Commons IO 2.1 Shipped All
jcommon.jar jfreechar.jar
LGPL
ZK PE and EE only
jasperreports.jar Required if you want itext.jar to use the jasperreport jxl.jar component. poi.jar commons-collections.jar commons-logging.jar commons-digester.jar bsh.jar Required if you want scripting in Java interpreter (BeanShell). Required if you want to use the captcha component.
LGPL (jasperreports)
Jasper Reports 4.5.1 (itext: 2.1.7, commons-collections: 3.2.1, commons-logging: 1.1.1, commons-digester: 2.1, jxl: 2.6.12, poi: 3.7) Note: poi.jar is required if you want to use Apache POI to generate Microsoft Excel format. And, jxl.jar is required only if you want to use JExcelApi to generate the Microsoft Excel format.
ZK PE and EE only
LGPL
BeanShell 2.0b4
All
Filters.jar
Apache
ZK PE and EE only
The interpreters for Groovy (groovy.jar), Ruby (jruby.jar), Python (jython.jar), JavaScript (js.jar), MVEL (mvel.jar) and OGNL (ognl.jar) are not shipped with the binary distribution since ZK 6. You could get them from
The Content of ZK Binary Distribution their websites, or from ZK's Git repository (https://github.com/zkoss/zk/tree/master/dist/lib/ext).
29
/dist/src
This directory holds the source codes in JAR format. These JAR files are used for debugging in IDE, such as Eclipse and NetBeans. You cannot build the binary libraries from these. Rather, download and uncompress zk-src-6.0.0.tar.gz.
/dist/xsd
This directory holds the XSD files that might be useful to develop ZK applications.
/dist/WEB-INF
This directory holds the sample configuration file (web.xml and portlet.xml) and the TLD files. These TLD files are part of JAR files so they are loaded automatically. We put them here mainly for your reference only.
Version History
Version Date Content
Setting up Servers
If you are new to Web servers, you could start with ZK Installation Guide/Setting up Servers/Tomcat.
Tomcat
30
Tomcat
Install Tomcat
1. Visit Tomcat Official Site [4] 2. Select the correct binary distribution for your environment and download For Windows, you might download and execute 32-bit/64-bit Windows Service Installer [2], and then follow the instructions Any download/install problem, please refer to http://tomcat.apache.org/tomcat-6.0-doc/index.html
Deploy
Deploy ZK demo application(optional)
The simplest way to test drive ZK existed application is to download and install the ZK demo application. This step is optional. You could skip it if you prefer to start creating your own application directly. 1. 2. 3. 4. 5. Download the lastest zkdemo at http://sourceforge.net/projects/zk1/files/ZK/(e.g. zk-sandbox-6.0.0.zip) Unzip zk-sandbox-6.0.0.zip Copy zkdemo.war under the zk-sandbox-6.0.0 directory to $TOMCAT_HOME/webapps. Start/ReStart the tomcat services (In some cases, you may need to restart your container if it is running.) Visit http://localhost:8080/zkdemo, and then play around with the demo application Deploy war file to Tomcat is very easy but there're something you need to know Tomcat will unzip the war file to filename\ directory automatically You can NOT modify the content of filename\ directory unless you remove the war file, or your modification will not work. For more information about Tomcat's deployer, please refer to http://tomcat.apache.org/tomcat-6.0-doc/ deployer-howto.html
Version History
Version Date Content
JBoss
31
JBoss
JBoss 4.0 and above
1. 2. 3. 4. 5. 6. 7. Download Jboss from http://www.jboss.com/downloads/index and install it,if you haven't installed it. Test the Jboss using link http://localhost:port, if it's OK stop the server. Unzip zk-demo-XXX.zip or zk-demo-XXX.tar.gz Copy dist/lib/*.jar and dist/lib/*/*.jar to the $JBOSS_HOME/server/default/lib Copy zkdemo.war to $JBOSS_HOME/server/default/deploy Start the server. Browse to http://localhost/zkdemo/userguide or http://localhost:8080/zkdemo/userguide depending on you configuration for JBoss.
Version History
Version Date Content
JBoss Cluster
32
JBoss Cluster
Before You Start
You have to configure the following setting for Web and JBoss.
web.xml
According to JBoss' tutorial, it is required to add the following settings in WEB-INF/web.xml if you are doing clustering in JBoss. <?xml version="1.0"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <distributable/> </web-app>
jboss-web.xml
Create jboss-web.xml file under under XXX/WEB-INF folder(XXX is like ZKsandbox in the war file) if fileupload component is used in your app. For example,
<jboss-web> <context-root>warFileName</context-root> <!-- context-root should be the same with wa <replication-config> <cache-name>standard-session-cache</cache-name> <replication-trigger>SET_AND_GET</replication-trigger> <replication-granularity>SESSION</replication-granularity> <replication-field-batch-mode>true</replication-field-batch-mode> <use-jk>true</use-jk> <max-unreplicated-interval>30</max-unreplicated-interval> <snapshot-mode>INSTANT</snapshot-mode> <snapshot-interval>1000</snapshot-interval> </replication-config> <max-active-sessions>5</max-active-sessions> <passivation-config> <use-session-passivation>true</use-session-passivation> <passivation-min-idle-time>60</passivation-min-idle-time> <passivation-max-idle-time>600</passivation-max-idle-time> </passivation-config> </jboss-web>
JBoss Cluster
33
References
[1] http:/ / docs. jboss. org/ jbossclustering/ cluster_guide/ 5. 1/ html-single/ index. html
WebSphere
IBM WebSphere
1. IBM offers a websphere application server community edition. Please go to http://www-128.ibm.com/ developerworks/downloads/ws/wasce/?S_TACT=105AGX10&S_CMP=WASCE to download it. 2. Follow the instruction to download, you might need to register for an account if you don't already have one. 3. Under downloads, choose Server and 32bit IBM SDK 1.4.2 SR4-1, procees to download. 4. Start the installer and accepts all defaults. 5. Once installation is completed, go to All Programs->IBM Websphere->Application Server->Profiles->Default->Start the Server, this will start the server. 6. Browse http://localhost:9060/ibm/console/secure/logon.do to deploy application 7. After deployed, applications can be access via http://localhost:9080/myapp 8. For additional documentation and tutorials, go to http://publib.boulder.ibm.com/wasce/Front_en.html ZK supports Servlet 2.3, 2.4 and later. The only difference is the content of WEB-INF/web.xml is a little bit different. Please refer to Sample of web.xml and Sample of web.xml for Servlet 2.3.
IBM WebSphere 7
Import war file 1. Applications -> Application Types -> WebSphere enterprise applications -> Click install button
2.
Select
war
file
to
import
WebSphere
34
3. Select Fast Pa Find web application port 1. Servers -> Server Types -> WebSphere application servers -> Click "server1"
2.
Communcations
->
Click
on
"Ports"
WebSphere
35
3.
36
Version History
Version Date Content
WebSphere Portal
37
WebSphere Portal
Setting up Websphere Portal
Download Websphere Portal from IBM [1] Follow the installation guide here [2] to install Browse http://localhost:10039/wps/portal and set up admin account and password
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"> <portlet> <portlet-name>zk</portlet-name> <display-name>zk</display-name> <portlet-class>org.zkoss.zk.ui.http.DHtmlLayoutPortlet</portlet-class> <init-param> <name>zk_page</name> <value>/index.zul</value> <!-- the main page of portlet --> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> </supports> <portlet-info> <title>zk</title> <short-title>zk</short-title> <keywords>zk</keywords> </portlet-info> <security-role-ref> <role-name>administrator</role-name> </security-role-ref> <security-role-ref> <role-name>guest</role-name> </security-role-ref>
WebSphere Portal <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref> </portlet> </portlet-app> Export the project as a war file
38
Select Web Module then click the install button. Click Choose File button to select the war file then press the Next button. Check the war information and choose Start application, then click the Finish button. Go back to Home page Add a new tab page by clicking Action -> EditPage Click New Page then enter "Page name" and "Friendly URL Name"
WebSphere Portal
39
Add the deployed portlet to the created new page by clicking Action -> EditPage. Click Customize -> All -> in the search box, enter the portlet name defined in portlet.xml Drag and drop the portlet into the created new page and click Save & Exit button. ZK project is now deployed in a Websphere Portal
WebSphere Portal
40
Version History
Version Date Content
References
[1] http:/ / www14. software. ibm. com/ webapp/ download/ byproduct. jsp?pgel=ibmhzn1& cm_re=masthead-_-supdl-_-dl-trials [2] http:/ / www-10. lotus. com/ ldd/ portalwiki. nsf/ dx/ Installing_wp7
Oracle Server
Oracle OC4J and Oracle OPMN Release 3
OC4J 10.1.3 (release 3) is the first production version of Oracle Containers to support J2EE 1.4 specification (Servlet 2.4). 1. Download OC4J 10.1.3 or later from http://www.oracle.com and install it. 2. You must setup OC4J to run with the -userThreads parameter at the command line (oc4j.cmd, on OPMN this is done inside the opmn.xml <data id="oc4j-options" value="-userThreads" />) 3. Unzip zk-1.2.0-2006-04-07.zip or later version 4. Copy dist/lib/*.jar and dist/lib/ext/*.jar to the $OC4J_HOME/j2ee/home/applib 5. Start OC4J server and enter a new oc4jadmin's password if prompted or restart the server if it is already up 6. Open "Enterprise Manager" application - just browse to http://localhost:8888/em/ 7. Login as oc4jadmin and go to Applications --> Deploy page 8. Deploy zkdemo.war (follow the on-screen instructions) 9. Browse to http://localhost:8888/zkdemo/userguide Substitute "/zkdemo" with the context uri you entered in EM during deployment Start OC4J Server: bin/oc4j -start
Version History
Version Date Content
WebLogic
41
WebLogic
1. Download Weblogic 9.1 from [1] 2. Start the Weblogic installer and accept all defaults. 3. Once the default installation is complete, create a weblogic domain by clicking Start->Programs->BEA products->Tools->Configuration Wizard. 4. Select "Create New Weblogic Domain" and click Next. 5. Accept the defaults on "Select Domain Source" and click Next. 6. Enter a password in "Configure Administrator Username and Password" and click Next. 7. Accept all defaults on "Configure Server Start Mode and JDK" and click Next. 8. Selct No on Configure Environment Setting and Services" and click Next. 9. Accept all defaults on "Create Weblogic Domain and click Create. 10. Once the domain is created, check the check box labeled "Start Admin Server" and click Done. 11. The server will start up. 12. The HTTP port is default to 7001 unless you change it. The easiest way to deploy your application is to copy your war/ear (it could be in an exploded format) to the autodeploy directory under the weblogic installaton directory. If you followed the instruction above that directory is located at C:\bea\user_projects\domains\base_domain\autodeploy. When you place your war/ear file in that directory, weblogic will detect it and do a hot deployment. If you want to copy ZK libraries to the domain, put them under c:/bea/user_projects/domains/base_domain/lib Libraries that have to be copied include bsh.jar, commons-fileupload.jar, commons-el.jar, pxcommon.jar, pxweb.jar, zk.jar, zul.jar, and zhtml.jar.
Version History
Version Date Content
References
[1] http:/ / commerce. bea. com/ showproduct. jsp?family=WLS& major=9. 1& minor=0
WebLogic Portal
42
WebLogic Portal
Introduction
Weblogic Portal provides several types of portlets, if you want to convert an existing zul page into a portlet, you can consider using a JSP portlet.
WebLogic Portal
43
4. Check Minmizable and Maximizable and you can define title and zul page location then click Create.
WebLogic Portal
44
WebLogic Portal
45
2. Done.
WebLogic Portal
46
Version History
Version Date Content
References
[1] http:/ / localhost:7001/ myPortalWebProject/ index. portal
WebLogic Cluster
47
WebLogic Cluster
Before You Start
You have to configure the following setting for ZK and Weblogic.
zk.xml
Turn on Serializable UI Factory for ZK, please refer to this documentation. <zk>
<system-config> <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-clas </system-config> <!-- clustering environment, since ZK 5.0.8--> <listener> <listener-class>org.zkoss.zkplus.cluster.ClusterSessionPatch</listener-class> </listener> </zk>
weblogic.xml
Add a weblogic.xml under XXX/WEB-INF folder(XXX is like ZKsandbox in the war file) For example, <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd"> <weblogic-web-app> <session-descriptor> <session-param> <param-name>PersistentStoreType</param-name> <param-value>replicated</param-value> </session-param> </session-descriptor> </weblogic-web-app> As mentioned in Weblogic's document [1]
replicated Same as memory, but session data is replicated across the clustered servers.
WebLogic Cluster
48
Version History
Version 5.0.8 Date June 2011 Content Add ClusterSessionPatch listener to zk.xml for enforce Weblogic to write session.
References
[1] http:/ / download. oracle. com/ docs/ cd/ E12840_01/ wls/ docs103/ webapp/ weblogic_xml. html#wp1071982 [2] http:/ / download. oracle. com/ docs/ cd/ E12840_01/ wls/ docs103/ cluster/ setup. html
account and download the App Engine SDK. Refer to the official
To use Google App Engine for Java, you have to take one additional step: sign up here [2]. In addition, since GAE is a clustered platform, your application must be ready for clustering, such as implementing serializable. For more information, please refer to ZK Developer's Reference: Clustering/Programming Tips.
49
<param-value>/zkau</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
<!-- clustering environment --> <system-config> <disable-event-thread/> <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-clas </system-config> <!-- clustering environment (available since ZK 5.0.8)--> <listener> <listener-class>org.zkoss.zkplus.cluster.ClusterSessionPatch</listener-class> </listener> <!-- [Required if ZK 5] disable the use of LogManager (prohibited by GAE). --> <library-property> <name>org.zkoss.util.logging.hierarchy.disabled</name> <value>true</value>
Google App Engine </library-property> <!-- GAE doesn't allow user's thread --> <client-config> <resend-delay>-1</resend-delay> </client-config> </zk> With ZK 6 or later, you don't have to specify the library property called org.zkoss.util.logging.hierarchy.disabled. Rather, just not to configure the logging at all (i.e., do not use any feature specified in ZK Developer's Reference/Supporting Utilities/Logger). Then, java.util.logging.LogManager won't be used (which is prohibited by GAE).
50
More Information
Due to the way App Engine serializes sessions, you have to use ZK 3.6.2 or later. In additions, there are some other limitations. You cannot define functions in zscript, since BeanShell's method can not be serialized correctly[4] . You cannot use captcha due to the limit support of AWT[5]
[1] [2] [3] [4] http:/ / code. google. com/ appengine/ http:/ / appengine. google. com/ promo/ java_runtime http:/ / code. google. com/ appengine/ docs/ java/ gettingstarted/ It runs correctly locally but not if uploaded. It could be done by specifying as a library property to disable the serializing of zscript methods for the whole application. [5] You will see a warning, ... Component captcha ignored., in the application log.
Google App Engine public class MyDesktopInit implements DesktopInit { public void init(Desktop desktop, Object req) throws Exception { HttpServletRequest request = (HttpServletRequest) req; //Remove old Desktop String oldDesktopId = (String) request.getSession().getAttribute("currentDesktopId"); WebAppCtrl ctrl = (WebAppCtrl)Executions.getCurrent().getDesktop().getWebApp(); DesktopCache dc = ctrl.getDesktopCache(desktop.getSession()); dc.removeDesktop(dc.getDesktop(oldDesktopId)); //Add new Desktop request.getSession().setAttribute("currentDesktopId", desktop.getId()); } }
51
Sample
Download (http:/ / sourceforge. net/ projects/ zk1/ files/ ZK for Google App Engine/ ) a sample application named zk-gae. You can visit it at http://zk-gae.appspot.com/hello.zul (http://zk-gae.appspot.com/hello.zul). In additions, you could visit Bitbucket (https:/ / bitbucket. org/ antiso/ zktest/ src/ 143186a3ae8b/ src/ main/ ). It is a sample project developed by Vladimir Sosnin, and the working demo is here (http:/ / tags42. appspot. com/ borderlayout/borderlayout.zul).
Version History
Version 5.0.8 5.0.9 Date June 2011 September 2011 Content Add ClusterSessionPatch listener to zk.xml for enforce GAE to write session. In 5.0.7/5.0.8, we introduced a feature allowing developers to log the serialization. Unfortunately, it broke one of GAE restriction: java.util.logging.LogManager is not accessible. It is fixed in 5.0.9 but specifying a library property called org.zkoss.util.logging.hierarchy.disabled in WEB-INF/zk.xml.
Heroku
52
Heroku
Get Your Heroku Ready
Refer to Getting Started with Heroku [1] for getting Heroku ready. You should have Ruby, Git, and Heroku Gem installed and have applied for a Heroku account.
Heroku
53
Heroku
54
<artifactId>tomcat-embed-logging-juli</artifactId> <version>7.0.22</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <version>7.0.22</version> </dependency> <!-- The following three dependencies are used for JSP. If you application doesn't contai <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jasper</artifactId> <version>7.0.22</version> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jasper-el</artifactId> <version>7.0.22</version> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jsp-api</artifactId> <version>7.0.22</version> </dependency> ... <!-- Add the plugin to start ''Main.class'' --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>appassembler-maven-plugin</artifactId> <version>1.1.1</version> <configuration> <assembleDirectory>target</assembleDirectory> <programs> <program> <mainClass>launch.Main</mainClass> <name>webapp</name> </program> </programs> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>assemble</goal> </goals> </execution> </executions>
Heroku </plugin> ... 7. Create a file named Procfile in Project root to tell Heroku how to execute the application web: sh target/bin/webapp
55
Deploy to Heroku
Once the server is ready, we can deploy to Heroku. 1. Initialize git repository. cd projectName git init 3. Create a .gitignore file to ignore all the files under target folder as these files are unnecessary to be managed and included by git repository. target
5. Commit project source code to git repository. git add . git commit -m "CommitMessageNote" 7. Create Heroku app on Cedar stack and Heroku will create an app with a random AppName that can be changed later: heroku create --stack cedar
Heroku
56
Sample
Download [3] the sample maven project named heroku_zksandbox.zip. Sandbox sample is deployed on Heroku at http://zksandbox.herokuapp.com/ [4].
References
[1] [2] [3] [4] http:/ / devcenter. heroku. com/ articles/ quickstart http:/ / books. zkoss. org/ wiki/ ZK_Installation_Guide/ Setting_up_IDE/ Maven/ Create_and_Run_ZK_Application_with_Maven_Archetype http:/ / sourceforge. net/ projects/ zkforge/ files/ Small%20Talks/ ZK%20Sandbox%20for%20Heroku/ http:/ / zksandbox. herokuapp. com/
57
58
Then OpenShift will build your project on cloud. Once it's done you can visit http:/ / AppName-DomainName. rhcloud.com/to see your application.
59
Once it's done you can visit http://appName-domainName.rhcloud.com/to see the result
[1] [2] [3] [4] [5] [6] [7] https:/ / www. redhat. com/ openshift/ community/ blogs/ deploying-java-apps-to-the-cloud-with-the-openshift-eclipse-plug-in http:/ / docs. redhat. com/ docs/ en-US/ OpenShift_Express/ 1. 0/ html/ User_Guide/ index. html https:/ / openshift. redhat. com/ app/ repo/ openshift. repo http:/ / www. youtube. com/ watch?v=KLtbuvyJFFE http:/ / www. cygwin. com/ http:/ / rubyforge. org/ projects/ rubygems By default the warName is ROOT within the pom.xml file. This will render the webapp contents at http:/ / app_name-namespace. rhcloud. com. If you change the warName in pom.xml to "app_name" or if the warName in deployments folder is "app_name.war", then your base URL would become http:/ / app_name-namespace. rhcloud. com/ app_name.
Sample
Download (http://sourceforge.net/projects/zkforge/files/Small Talks/ZK Sandbox for OpenShift/?) the sample maven project named openshift_zksandbox.zip. Sandbox sample is deployed on OpenShift at http://zksandbox-zksupport.rhcloud.com/.
Liferay
60
Liferay
Setting up Liferay
There are several ways in which an application can be set up within Liferay, the first one being to simply go to Liferay [1] and download the pre-bundled liferay tomcat bundle (other app server bundles are also available but experiences indicate that other ones might be trickier to begin with as the configuration is usually more lengthy), however, this option is not ideal if the user already have an existing tomcat server. If the user already has a tomcat server on hand and does not particularly feel like deploying another one, the second option would be to download "liferay war". Typically, Liferay's installation removes the ROOT folder from the server, to avoid this situation, please stick to the following steps closely. Download the non-bundled liferay war (Liferay Portal Professional 4.2.1 WAR) from Liferay [1] Download the additional file called Liferay Portal 4.2.1 Dependencies, and unzip it to shared/lib In order to keep the ROOT folder, extract the contents of the war into a folder, call it 'myportal' for instance. Under the WEB-INF folder, create a 'classes' folder, in this folder create a file called 'portal-ext.properties', and in this file place the following (note that users may of course change the portal.ctx and/or the lucene and jackrabbit directory depending on later configurations): portal.release=professional portal.ctx=/myportal auto.deploy.dest.dir=../webapps portal.instances=1 lucene.dir=C:/home/liferay/lucene jcr.jackrabbit.repository.root=C:/home/liferay/jackrabbit omniadmin.users=
Go back to the WEB-INF folder and edit the web.xml - change the root_path to have a param value of '/myportal', so that the top of the web.xml will look as follows: <?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSch xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <context-param> <param-name>company_id</param-name> <param-value>liferay.com</param-value> </context-param> <context-param> <param-name>root_path</param-name> <param-value>/myportal</param-value> </context-param> <filter> <filter-name>Auto Login Filter</filter-name>
<filter-class>com.liferay.portal.servlet.filters.autologin.AutoLoginFilter</f
Liferay </filter> . . . Now go into the META-INF folder and add a file called 'context.xml' and add the following (configure this according to own specifics, just make sure that the context path attribute is '/myportal', if the user does not use mysql database and wants liferay to use hSQLdb, strip out the first Resource element): <Context path="/myportal" reloadable="true" > <Resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8" username="liferay" password="yarefil" maxActive="100" maxIdle="30" maxWait="10000" /> <Resource name="mail/MailSession" auth="Container" type="javax.mail.Session" mail.transport.protocol="smtp" mail.smtp.host="localhost" /> <Realm className="org.apache.catalina.realm.JAASRealm" appName="PortalRealm" userClassNames="com.liferay.portal.security.jaas.PortalPrincipal" roleClassNames="com.liferay.portal.security.jaas.PortalRole" debug="99" useContextClassLoader="false" /> </Context> Now for the real trick, liferay 4.2 has a small bug when changing the context to something other than the ROOT. In the folder html/portal, find a file called load_render_portlet.jsp, open the file up and go to line 55-56 and it should look like the following: function <%= namespace %>loadPortlet() { var path = "/c/portal/render_portlet"; however it should look as follows:
61
Liferay function <%= namespace %>loadPortlet() { var path = "/myportal/c/portal/render_portlet"; If the user wishes to use mySQL, modify the context.xml to the user's own configurations, the user will also need to download the liferay-mysql script file and run it against the user's database. Now, in the ROOT folder (i.e. C:\ for windows, / for UNIX/LINUX), create a 'home' folder (if it doesn't already exist) and in that folder, create a 'liferay' folder. Make sure tomcat has permission to modify the folder. Now, re zip the folder and rename the zip file to myportal.war, drop it into tomcat's webapps deploy directory and (hopefully) a working liferay portal will appear.
62
Deploying a ZK portlet
Here, this guide assumes that users are familiar with and have created a ZK war. First, in order to tell liferay about the portlet, create a class that looks like this: /** * Copyright (c) 2000-2006 Liferay, LLC. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */
Liferay
63
package za.co.mypackage.portlet; import java.io.IOException; import import import import import import import javax.portlet.ActionRequest; javax.portlet.ActionResponse; javax.portlet.GenericPortlet; javax.portlet.PortletException; javax.portlet.PortletRequestDispatcher; javax.portlet.RenderRequest; javax.portlet.RenderResponse;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * @author Brian Wing Shun Chan * @modified Glenn Keith */ public class JSPPortlet extends GenericPortlet { public void init() throws PortletException { editJSP = getInitParameter("edit-jsp"); helpJSP = getInitParameter("help-jsp"); viewJSP = getInitParameter("view-jsp"); } public void doDispatch(RenderRequest req, RenderResponse res) throws IOException, PortletException { String jspPage = req.getParameter("jspPage"); if (jspPage != null) { include(jspPage, req, res); } else { super.doDispatch(req, res); } } public void doEdit(RenderRequest req, RenderResponse res) throws IOException, PortletException { if (req.getPreferences() == null) { super.doEdit(req, res); }
Liferay else { include(editJSP, req, res); } } public void doHelp(RenderRequest req, RenderResponse res) throws IOException, PortletException { include(helpJSP, req, res); } public void doView(RenderRequest req, RenderResponse res) throws IOException, PortletException { include(viewJSP, req, res); } protected void include(String path, RenderRequest req, RenderResponse res) throws IOException, PortletException { PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(path); if (prd == null) { _log.error(path + " is not a valid include"); } else { prd.include(req, res); } } protected String editJSP; protected String helpJSP; protected String viewJSP; private static Log _log = LogFactory.getLog(JSPPortlet.class); } Next, create a 'liferay-display.xml' file that looks like the following in WEB-INF:
64
<?xml version="1.0"?> <!DOCTYPE display PUBLIC "-//Liferay//DTD Display 4.0.0//EN" "http://www.liferay.com/dtd/ <display> <category name="category.test"> <portlet id="portletone" />
Liferay </category> </display> Now, also in the WEB-INF, create a file called 'liferay-portlet.xml' that looks like the following:
65
<?xml version="1.0"?> <!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 4.1.0//EN" "htt <liferay-portlet-app> <portlet> <portlet-name>portletone</portlet-name> <instanceable>true</instanceable> </portlet> <role-mapper> <role-name>administrator</role-name> <role-link>Administrator</role-link> </role-mapper> <role-mapper> <role-name>guest</role-name> <role-link>Guest</role-link> </role-mapper> <role-mapper> <role-name>power-user</role-name> <role-link>Power User</role-link> </role-mapper> <role-mapper> <role-name>user</role-name> <role-link>User</role-link> </role-mapper> </liferay-portlet-app> Liferay 5.2.* : Liferay 5.2 adds cache filters to users' web.xml when deployed on the liferay server. These, however, blocks the zk javascript (*.js) communication. To avoid this, add the property "speed-filters-enabled=false" in the liferay-plugin-package.properties file in the WEB-INF directory. Now again in WEB-INF create a 'portlet.xml' file that looks as follows: <?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> <portlet> <portlet-name>portletone</portlet-name> <display-name>Sample JSP Portlet</display-name> <portlet-class>za.co.mypackage.JSPPortlet</portlet-class> <init-param> <name>view-jsp</name>
Liferay <value>/view.zul</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> </supports> <portlet-info> <title>Sample JSP Portlet</title> <short-title>Sample JSP Portlet</short-title> <keywords>Sample JSP Portlet</keywords> </portlet-info> <security-role-ref> <role-name>guest</role-name> </security-role-ref> <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref> </portlet> </portlet-app> Note that the /view.zul reference in this file is the 'index' file of the portlet, and all these files have been referenced as 'portletone', please change this as the name of the war file. Finally, at the top of the web.xml file after <web-app> add the following (followed by the typical ZK stuff): . . .
66
<display-name>sample-jsp-portlet</display-name> <context-param> <param-name>company_id</param-name> <param-value>liferay.com</param-value> </context-param> <listener> <listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</lis </listener> . . . Notice that company_id is left as liferay.com.This is because changing the value would also mean digging around the liferay database and it would be hard to find all the places to modify the values. Deploy the resulting war into /home/liferay/deploy directory, Access and sign in to the user's portal, click on 'Add Content' link, under the category 'Test' add 'Sample JSP Portlet'.
Liferay
67
<?xml version="1.0" encoding="UTF-8"?> <portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> <portlet> <description xml:lang="EN">HelloZK</description> <portlet-name>HelloZK</portlet-name> <display-name xml:lang="EN">HelloZK</display-name> <portlet-class>org.zkoss.zk.ui.http.DHtmlLayoutPortlet</portlet-class> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <supported-locale>en</supported-locale> <portlet-info> <title>HelloZK Portlet</title> <short-title>HelloZK</short-title> <keywords>zk</keywords> </portlet-info> <portlet-preferences> <preference> <name>zk_page</name> <value>/hello.zul</value> </preference> </portlet-preferences>
Liferay <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref> <security-role-ref> <role-name>administrator</role-name> </security-role-ref> </portlet> </portlet-app> liferay-display.xml
68
<?xml version="1.0"?> <!DOCTYPE display PUBLIC "-//Liferay//DTD DISPLAY 2.0.0//EN" "http://www.liferay.com/dtd/ <display> <category name="category.sample"> <portlet id="HelloZK" /> </category> </display> liferay-portlet.xml
<?xml version="1.0"?> <!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "htt <liferay-portlet-app> <portlet> <portlet-name>HelloZK</portlet-name> <header-portlet-javascript>/zkau/web/js/zk.wpd</header-portlet-javascript> </portlet> <role-mapper> <role-name>user</role-name> <role-link>User</role-link> </role-mapper> <role-mapper> <role-name>power-user</role-name> <role-link>Power User</role-link> </role-mapper> <role-mapper> <role-name>administrator</role-name> <role-link>Administrator</role-link> </role-mapper> </liferay-portlet-app> liferay-plugin-package.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plugin-package PUBLIC "-//Liferay//DTD Plugin Package 4.3.6//EN" "http://www.li <plugin-package>
Liferay <name>Hello ZK</name> <module-id>/com/demo/test/hellozk/war</module-id> <types> <type>portlet</type> </types> <tags> <tag>Hello ZK</tag> </tags> <short-description> Hello ZK </short-description> <change-log> Initial Deployment </change-log> <author>Sam</author> <licenses> <license osi-approved="true">GPL</license> </licenses> <liferay-versions> <liferay-version>5.1.1+</liferay-version> <liferay-version>5.2.1+</liferay-version> </liferay-versions> </plugin-package> 4.Add library-property setting to zk.xml for Liferay Reason: under IE, using Liferay with ZK will cause HTML Parsing Error (KB927917) Solution: use jQueryPatch and set appropriate time delay value for browser. zk.xml <zk> . . . <library-property> <name>org.zkoss.zk.portlet.PageRenderPatch.class</name> <value>org.zkoss.zkplus.liferay.JQueryRenderPatch</value> </library-property> <library-property> <name>org.zkoss.zkplus.liferary.jQueryPatch</name> <value>500</value> </library-property> . . . </zk>
69
Liferay 5. Export war file Export a war file called DEPLOY_TO__HelloZK.war, and put this war file under the deploy folder Liferay deploys war files by its name, when the name DEPLOY_TO__HelloZK.war is used, liferay will deploy this war file to folder HelloZK Download DEPLOY_TO__HelloZK.war [2]
70
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSch <display-name>HelloZK2</display-name> <filter> <filter-name>Cache Filter - Resource</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name> <param-value>com.liferay.portal.servlet.filters.cache.CacheFilter</para </init-param> <init-param> <param-name>url-regex-ignore-pattern</param-name> <param-value>.+/-/.+</param-value> </init-param> <init-param> <param-name>pattern</param-name> <param-value>2</param-value> </init-param> </filter> <filter> <filter-name>Cache Filter - Resource JSP</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name> <param-value>com.liferay.portal.servlet.filters.cache.CacheFilter</para </init-param> <init-param> <param-name>url-regex-pattern</param-name>
Liferay
71
<param-value>.+/(css|main)\.jsp</param-value> </init-param> <init-param> <param-name>pattern</param-name> <param-value>2</param-value> </init-param> </filter> <filter> <filter-name>ETag Filter</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name> <param-value>com.liferay.portal.servlet.filters.etag.ETagFilter</param</init-param> <init-param> <param-name>url-regex-ignore-pattern</param-name> <param-value>.+/-/.+</param-value> </init-param> </filter> <filter> <filter-name>ETag Filter - JSP</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name> <param-value>com.liferay.portal.servlet.filters.etag.ETagFilter</param</init-param> <init-param> <param-name>url-regex-pattern</param-name> <param-value>.+/(css|main)\.jsp</param-value> </init-param> </filter> <filter> <filter-name>GZip Filter</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name> <param-value>com.liferay.portal.servlet.filters.gzip.GZipFilter</param</init-param> </filter> <filter> <filter-name>Header Filter</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name>
<param-value>com.liferay.portal.servlet.filters.header.HeaderFilter</pa </init-param>
Liferay
72
<init-param> <param-name>url-regex-ignore-pattern</param-name> <param-value>.+/-/.+</param-value> </init-param> <init-param> <param-name>Cache-Control</param-name> <param-value>max-age=315360000, public</param-value> </init-param> <init-param> <param-name>Expires</param-name> <param-value>315360000</param-value> </init-param> <init-param> <param-name>Vary</param-name> <param-value>Accept-Encoding</param-value> </init-param> </filter> <filter> <filter-name>Header Filter - JSP</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name>
<param-value>com.liferay.portal.servlet.filters.header.HeaderFilter</pa </init-param> <init-param> <param-name>url-regex-pattern</param-name> <param-value>.+/(css|main)\.jsp</param-value> </init-param> <init-param> <param-name>Cache-Control</param-name> <param-value>max-age=315360000, public</param-value> </init-param> <init-param> <param-name>Expires</param-name> <param-value>315360000</param-value> </init-param> <init-param> <param-name>Vary</param-name> <param-value>Accept-Encoding</param-value> </init-param> </filter> <filter> <filter-name>Language Filter</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name>
Liferay
73
<param-value>com.liferay.portal.servlet.filters.minifier.MinifierFilter </init-param> </filter> <filter> <filter-name>Minifier Filter - JSP</filter-name> <filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filt <init-param> <param-name>filter-class</param-name>
<param-value>com.liferay.portal.servlet.filters.minifier.MinifierFilter </init-param> <init-param> <param-name>url-regex-pattern</param-name> <param-value>.+/(css|main)\.jsp</param-value> </init-param> </filter> <filter-mapping> <filter-name>Header Filter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Header Filter</filter-name> <url-pattern>*.gif</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Header Filter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Header Filter</filter-name> <url-pattern>*.ico</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Header Filter</filter-name> <url-pattern>*.jpg</url-pattern> </filter-mapping> <filter-mapping>
Liferay <filter-name>Header Filter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Header Filter</filter-name> <url-pattern>*.png</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Header Filter - JSP</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.gif</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.ico</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.jpg</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter</filter-name> <url-pattern>*.png</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ETag Filter - JSP</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Cache Filter - Resource</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping>
74
Liferay
75 <filter-mapping> <filter-name>Cache Filter - Resource</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Cache Filter - Resource</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Cache Filter - Resource JSP</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>GZip Filter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>GZip Filter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>GZip Filter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>GZip Filter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Language Filter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Minifier Filter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Minifier Filter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Minifier Filter - JSP</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <listener> <description>ZK listener for session cleanup</description> <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
76
<listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttribut </listener> <listener> <listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</lis </listener> <servlet> <description>ZK loader for ZUML pages</description> <servlet-name>zkLoader</servlet-name> <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> <init-param> <param-name>update-uri</param-name> <param-value>/zkau</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <description>The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet> <servlet-name>dspLoader</servlet-name> <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class> <init-param> <param-name>class-resource</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet> <servlet-name>HelloZK</servlet-name> <servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-clas <init-param> <param-name>portlet-class</param-name> <param-value>org.zkoss.zk.ui.http.DHtmlLayoutPortlet</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet> <servlet-name>HelloZK2</servlet-name> <servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-clas <init-param> <param-name>portlet-class</param-name> <param-value>org.zkoss.zk.ui.http.DHtmlLayoutPortlet</param-value> </init-param>
Liferay <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.svg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.xml2html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.mul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dspLoader</servlet-name> <url-pattern>*.dsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HelloZK</servlet-name> <url-pattern>/HelloZK/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HelloZK2</servlet-name> <url-pattern>/HelloZK2/*</url-pattern> </servlet-mapping> <session-config> <session-timeout>3</session-timeout> </session-config> <mime-mapping> <extension>doc</extension>
77
Liferay <mime-type>application/vnd.ms-word</mime-type> </mime-mapping> <mime-mapping> <extension>gif</extension> <mime-type>image/gif</mime-type> </mime-mapping> <mime-mapping> <extension>htm</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>html</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> <mime-mapping> <extension>jpeg</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>jpg</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>js</extension> <mime-type>application/x-javascript</mime-type> </mime-mapping> <mime-mapping> <extension>pdf</extension> <mime-type>application/pdf</mime-type> </mime-mapping> <mime-mapping> <extension>png</extension> <mime-type>image/png</mime-type> </mime-mapping> <mime-mapping> <extension>rar</extension> <mime-type>application/x-rar-compressed</mime-type> </mime-mapping> <mime-mapping> <extension>txt</extension> <mime-type>text/plain</mime-type> </mime-mapping> <mime-mapping>
78
Liferay
79
<extension>xls</extension> <mime-type>application/vnd.ms-excel</mime-type> </mime-mapping> <mime-mapping> <extension>xml</extension> <mime-type>text/xml</mime-type> </mime-mapping> <mime-mapping> <extension>xul</extension> <mime-type>application/vnd.mozilla.xul-xml</mime-type> </mime-mapping> <mime-mapping> <extension>zhtml</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>zip</extension> <mime-type>application/x-zip</mime-type> </mime-mapping> <mime-mapping> <extension>zul</extension> <mime-type>text/html</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> <jsp-config> <taglib> <taglib-uri>http://liferay.com/tld/aui</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-aui.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://liferay.com/tld/portlet</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-portlet-ext.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://liferay.com/tld/security</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-security.tld</taglib-location> </taglib> <taglib>
Liferay
80
<taglib-uri>http://liferay.com/tld/theme</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-theme.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://liferay.com/tld/ui</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://liferay.com/tld/util</taglib-uri> <taglib-location>/WEB-INF/tld/liferay-util.tld</taglib-location> </taglib> </jsp-config> </web-app> zk.xml: use JQueryRenderCachedPatch <?xml version="1.0" encoding="UTF-8"?> <zk> <library-property> <name>org.zkoss.zk.portlet.PageRenderPatch.class</name> <value>org.zkoss.zkplus.liferay.JQueryRenderCachedPatch</value> </library-property> <library-property> <name>org.zkoss.zkplus.liferary.jQueryPatch</name> <value>1500</value> </library-property> </zk> [since 5.0.11] use NonRootContextJQueryRenderPatch instead of JQueryRenderCachedPatch if the home page of Liferay is not under the root(/) path <?xml version="1.0" encoding="UTF-8"?> <zk> <library-property> <name>org.zkoss.zk.portlet.PageRenderPatch.class</name> <value>org.zkoss.zkplus.liferay.NonRootContextJQueryRenderPatch</value> </library-property> <library-property> <name>org.zkoss.zkplus.liferary.jQueryPatch</name> <value>1500</value> </library-property> </zk> liferay-portlet.xml: add this to the setting <header-portlet-javascript>/zkau/web/js/zk.wpd</header-portlet-javascript>
Liferay
81
<liferay-portlet-app> <portlet> <portlet-name>HelloZK2</portlet-name> <header-portlet-javascript>/zkau/web/js/zk.wpd</header-portlet-javascript> </portlet> <role-mapper> <role-name>user</role-name> <role-link>User</role-link> </role-mapper> <role-mapper> <role-name>power-user</role-name> <role-link>Power User</role-link> </role-mapper> <role-mapper> <role-name>administrator</role-name> <role-link>Administrator</role-link> </role-mapper> </liferay-portlet-app> liferay-display.xml
<?xml version="1.0"?> <!DOCTYPE display PUBLIC "-//Liferay//DTD DISPLAY 2.0.0//EN" "http://www.liferay.com/dtd/ <display> <category name="category.sample"> <portlet id="HelloZK2" /> </category> </display> liferay-plugin-package.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plugin-package PUBLIC "-//Liferay//DTD Plugin Package 4.3.6//EN" "http://www.li <plugin-package> <name>Hello ZK2</name> <module-id>/com/demo/test/hellozk2/war</module-id> <types> <type>portlet</type> </types> <tags> <tag>Hello ZK2</tag> </tags> <short-description> Hello ZK2 </short-description> <change-log> Initial Deployment </change-log>
Liferay
82
<author>Sam</author> <licenses> <license osi-approved="true">GPL</license> </licenses> <liferay-versions> <liferay-version>6.0.0+</liferay-version> <liferay-version>6.0.0+</liferay-version> </liferay-versions> </plugin-package> portlet.xml <?xml version="1.0" encoding="UTF-8"?> <portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> <portlet> <description xml:lang="EN">HelloZK2</description> <portlet-name>HelloZK2</portlet-name> <display-name xml:lang="EN">HelloZK2</display-name> <portlet-class>org.zkoss.zk.ui.http.DHtmlLayoutPortlet</portlet-class> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <supported-locale>en</supported-locale> <portlet-info> <title>HelloZK2 Portlet</title> <short-title>HelloZK2</short-title> <keywords>zk2</keywords> </portlet-info> <portlet-preferences> <preference> <name>zk_page</name> <value>/hello.zul</value> </preference> </portlet-preferences> <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref>
Liferay <security-role-ref> <role-name>administrator</role-name> </security-role-ref> </portlet> </portlet-app> Please download the following war file to view this example in detail Download DEPLOY_TO__HelloZK2.war [4]
83
See also
http://devenphillips.blogspot.com/2009/04/developing-liferay-portlets-with-zk.html ZK 5 / Liferay Integration - jquery conflict [5]
Version History
Version Date Content
References
[1] http:/ / www. liferay. com [2] https:/ / sourceforge. net/ projects/ zkforge/ files/ Small%20Talks/ How%20to%20Install%20ZK%20on%20Liferay/ DEPLOY_TO__HelloZK. war/ download [3] http:/ / www. liferay. com/ [4] https:/ / sourceforge. net/ projects/ zkforge/ files/ Small%20Talks/ How%20to%20Install%20ZK%20on%20Liferay/ DEPLOY_TO__HelloZK2. war/ download [5] http:/ / www. zkoss. org/ forum/ listComment/ 11051
Pluto
84
Pluto
Deploy a ZK Porlet
web.xml
Define the definition of porlet in web.xml <web-app> <display-name>ZK Portlets</display-name> <servlet> <description>ZK loader for ZUML pages</description> <servlet-name>zkLoader</servlet-name> <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> <init-param> <param-name>update-uri</param-name> <param-value>/zkau</param-value> </init-param> <load-on-startup>1</load-on-startup><!-- Must --> </servlet> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> <servlet> <description>The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <servlet> <servlet-name>zkportlet</servlet-name> <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class> <init-param> <param-name>portlet-name</param-name> <param-value>zkportlet</param-value>
Pluto </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>zkportlet</servlet-name> <url-pattern>/PlutoInvoker/zkportlet</url-pattern> </servlet-mapping> <session-config> <session-timeout>120</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> <security-role> <role-name>tomcat</role-name> </security-role> </web-app>
85
portlet.xml
Define a ZK portlet in portlet.xml. <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
<portlet> <description>ZKloader for ZUML pages</description> <portlet-name>zkportlet</portlet-name> <display-name>ZK Portlet Loader</display-name> <portlet-class>org.zkoss.zk.ui.http.DHtmlLayoutPortlet</portlet-class> <init-param> <name>zk_page</name> <value>/index.zul</value> </init-param> <expiration-cache>0</expiration-cache>
Pluto
86
<supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <supported-locale>en</supported-locale> <portlet-info> <title>ZK</title> <short-title>ZK</short-title> <keywords>ZK,ZUML</keywords> </portlet-info> <security-role-ref> <role-name>plutoTestRole</role-name> <role-link>tomcat</role-link> </security-role-ref> </portlet> </portlet-app>
Version History
Version Date Content
Jetty
87
Jetty
1. 2. 3. 4. Download Jetty from http://www.mortbay.org/jetty/index.html and install it, if you haven't installed it yet. Stop Jetty. Unzip zk-demo-x.x.x.zip or zk-demo.x.x.tar.gz Copy dist/lib/*.jar to $JETTY_HOME/lib
($JETTY_HOME is where you installed Jetty) 5. Copy dist/lib/ext/*.jar to $JETTY_HOME/lib 6. [Optional] Copy dist/lib/zkforge/*.jar to $JETTY_HOME/lib (It depends whether you need component from ZK Forge) 7. Deploy demo/bin/zkdemo.war to Jetty by copying it to $JETTY_HOME/webapps directly. 8. Start Jetty. 9. Browse to http://localhost/zkdemo/userguide or http://localhost:8080/zkdemo/userguide, depending on your configuration.
Version History
Version Date Content
Resin
1. 2. 3. 4. 5. 6. Download Resin from http://caucho.com/download/index.xtp and install it, if you haven't installed it yet. Stop Resin Unzip zk-1.0.0.zip or zk-1.0.0.tar.gz Copy dist/lib/*.jar to $RESIN_HOME/lib ($RESIN_HOME is where you installed Resin.) Copy dist/lib/ext/*.jar to $RESIN_HOME/lib [Optional] Copy dist/lib/zkforge/*.jar to $RESIN_HOME/lib (It depends whether you need component from ZK Forge) 7. Deploy demo/bin/zkdemo.war to Resin by copying it to $RESIN_HOME/webapps directly. 8. Start Resin. 9. Browse to http://localhost/zkdemo/userguide or http://localhost:8080/zkdemo/userguide, depending on your configuration. by Peter Manchev
Version History
Version Date Content
Setting up OSGi
88
Setting up OSGi
This installation guide will lead you through how to run ZK in OSGi environment. If you are not familiar to OSGi, following are some useful references: OSGi official home page [1] OSGi Service Platform Release 4 [2] OSGI Service Platform Release 4 Java API [3] Hello, OSGi Part 1 [4], Part 2 [5], Part 3 [6] Apache Felix OSGi Tutorial [7]
References
[1] [2] [3] [4] [5] [6] http:/ / www. osgi. org/ Main/ HomePage http:/ / www2. osgi. org/ Release4/ HomePage http:/ / www2. osgi. org/ javadoc/ r4/ http:/ / www. javaworld. com/ javaworld/ jw-03-2008/ jw-03-osgi1. html http:/ / www. javaworld. com/ javaworld/ jw-04-2008/ jw-04-osgi2. html http:/ / www. javaworld. com/ javaworld/ jw-06-2008/ jw-06-osgi3. html
89
ZK OSGi bundles
since 6.0.2 Download ZK OSGi [2] jars. Unzip all zk osgi jars into any folder. Double click EclipseRTWebStarterKit.target file.
Click Add button -> choose Directory -> Select the folder that contains zk osgi jars. Click Set as Target Platform link to make it a default target platform to run OSGi Framework.
90
If you see osgi console, then it is correctly installed. You can type help command to check all osgi command usage.
Type close command in the console to shutdown and exit OSGi environment.
91
4. In Build tab, remember to check WEB-INF folder and index.zul file that were created earlier.
92
6. In MANIFEST.MF tab, add the following content to the last line that will treat this plug-in project as a web bundle. Web-ContextPath: /osgi
Right click on helloZKOSGi project -> Run AS -> Run Configuration Click Add Required Bundles button and make sure that helloZKOSGi bundle is checked Visit http://localhost:8080/osgi to check the result.
Version History
Version Date Content
References
[1] http:/ / download. eclipse. org/ jetty/ updates/ jetty-rt-3. 7milestones/ [2] http:/ / sourceforge. net/ projects/ zk1/ files/ ZK/ zk-6. 0. 2/
Setting up OS
93
Setting up OS
Here is the information related to the OS environment that some ZK components might depend on.
Linux
Here is the notes to set up the environment of Linux that some ZK components depends on.
Jaspserreport
Jasperreprot is based on the JasperReports project (http:/ / jasperforge. org/ projects/ jasperreports). To make it run correctly under Linux, you have to make sure all fonts that you use are installed. sudo aptitude install msttcorefonts sudo /etc/init.d/tomcat6 restart
The procedure to install fonts might depend on the version you use. Please refer to this discussion (http:/ / stackoverflow.com/questions/3218732/jasper-reports-pdf-generation-issue) for more information.
Version History
Version Date Content
IOS
94
IOS
Here is the notes to set up the environment of iOS.
Columns Menu
Several components, such as Columns Menu, will adjust the position of popup to make sure it is on the left side of the right edge (so that it is totally visible). On the other hand, iOS Safari assumes the width to be 980px by default. Thus, if your web page is designed to have a different width, the calculation might be wrong. To solve this issue, you could specify the width in a meta tag called viewport as follows: <meta name="viewport" content="width=1190" > For more information, please refer to Safari Developer Library [1].
onClick Event
In IOS device (ipad/iphone) you have to specify the following CSS (cursor:pointer) to make it work with onClick event. <component style="cursor:pointer">
Version History
Version Date Content
IOS
95
References
[1] http:/ / developer. apple. com/ library/ safari/ #documentation/ AppleApplications/ Reference/ SafariWebContent/ UsingtheViewport/ UsingtheViewport. html#/ / apple_ref/ doc/ uid/ TP40006509-SW24
Install ZK Studio
Follow ZK Studio Installation Guide to install ZK Studio.
For example, the root directory of Apache Tomcat might be C:\Program Files\Apache Software Foundation\Tomcat 6.0 For how to install Tomcat, please refer to this section 5. Click Finish
96
Version History
Version Date Content
97
How to generate ZUL files from the ZUL schema using Eclipse
1. 2. 3. 4. 5. You should have setup the zul.xsd schema into Eclipse. Select File/New/Other... from the Eclipse SDK menu and the New dialog popup. In Select a wizard page, select XML/XML from the tree menu and press Next > button. In Create XML File page, select Create XML file from an XML schema file and then press Next > button. In XML File Name page, type or select a proper parent folder for your project. It is generally under the WebContext folder of your project. Then type in the ZUL file name you want to create(e.g. helloworld.zul) and press Next > button. 6. In Select XML Schema File page, select Select XML catalog entry option. You should see the http://www. zkoss.org/2005/zul/zul.xsd''' in the XML Catalog list. Now select the entry and press Next > button. 7. In Select Root Element page: In Root Element field, pick a proper root element. In most ZK applications, it is generally a window or an zk element. In Content options field, you can leave as it is. In Namespace Information field, you can select the entry and press edit... button to take out the prefix or change the prefix. Press Finish button. 8. The ZUL file is created and opened on an XML editor window. 9. Now you can start editing your ZUL file. Press Alt-/ to open the Content Assist popup window to help you fill up proper ZUL elements and attributes. 10. Done.
98
How to setup the Rational Application Developer RAD version of Eclipse to work with zhtml
1. 2. 3. 4. Select Window/Preferences... from the SDK menu and the Preferences dialog will popup. Select Workbench/File Assocations then click on the top Add to add a file type *.zhtml Click on the lower Add and select HTML Source Page Editor and set it to be default Done
See Also
Develop ZK Applications with Eclipse [2]
Version History
Version Date Content
References
[1] http:/ / www. zkoss. org/ product/ zkstudio. dsp [2] http:/ / www. zkoss. org/ smalltalks/ eclipse/ ek. html
Maven
If you don't know what Maven is, please take a look at the following URL(s): Maven Apache http://maven.apache.org/ Maven in 5 Minutes http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
99
Prerequirement
JAVA SDK : Java 5 or above is required to run Eclipse and Embedded Maven (you can still use any Java version as default in Eclipse and run external Maven using Java versions required by Maven) Make sure Eclipse is running on JDK and not on JRE
Eclipse Related
Eclipse : 3.6 or later Go to Eclipse Downloads [1] Choose Eclipse IDE for Java EE Developers (It included WTP [2]) Eclipse Plugin, which can be installed by using the Eclipse Update Manager. The Eclipse Update Manager can be found by selecting Install New Software... from the Help menu. Then, click Add... to add the URL as a new update site. 1. M2eclipse[3] : Update Site : Eclipse 3.6.* and 3.7.*: http://download.eclipse.org/technology/m2e/releases [4] (Recommend) Eclipse 3.5.* and 3.6.*: http:/ / m2eclipse. sonatype. org/ sites/ m2e [5] (Please note: This version includes a Maven Archetype Bug. Therefore it is suggested to download and install a "newer" version of M2eclipse plugin to avoid this unresolved error.) Install Maven Integration for Eclipse (core feature)
2. (Optional but recommend) Run-Jetty-Run Update Site : http://run-jetty-run.googlecode.com/svn/trunk/updatesite/ [6] An amazing plug-in which enables you to run web applications in Eclipse using its embedded Jetty distribution. You will enjoy the awesome redeploy speed. Installation and usage documentation Run-Jetty-Run - Getting Started [7] 3. (Optional) M2eclipse Extra[8] Update Site : http://m2eclipse.sonatype.org/sites/m2e-extras [9] Install Maven Integration for WTP
100
4. (Optional) Eclipse IAM, formerly Q for Eclipse: Eclipse Integration for Apache Maven Q4e on Google Code [10] 5. (Optional) Subeclipse Get the latest subclipse plug-in as per plug-in instructions here update_1.6.x)
[11]
Note: For 64-bit Windows & 64-bit Eclipse installation you will need to install Silksvn client download [12] to avoid JavaHL binding error.
[1] http:/ / www. eclipse. org/ downloads [2] http:/ / www. eclipse. org/ webtools/ [3] Official installation step Eclipse 3.6.* and 3.7.*: (http:/ / eclipse. org/ m2e/ download/ ) Eclipse 3.5.* and 3.6.*: (http:/ / m2eclipse. sonatype. org/ installing-m2eclipse. html) [4] http:/ / download. eclipse. org/ technology/ m2e/ releases [5] http:/ / m2eclipse. sonatype. org/ sites/ m2e [6] http:/ / run-jetty-run. googlecode. com/ svn/ trunk/ updatesite/ [7] http:/ / code. google. com/ p/ run-jetty-run/ wiki/ GettingStarted [8] This plugin should be installed when you use WTP as your development server. [9] http:/ / m2eclipse. sonatype. org/ sites/ m2e-extras [10] http:/ / code. google. com/ p/ q4e/ [11] http:/ / subclipse. tigris. org/ install. html [12] http:/ / www. sliksvn. com/ en/ download
Version History
Version Date Content
101
Resolving ZK Framework Artifacts via Maven In order for Maven to successfully resolve these dependencies groupid and artifactid must match with those published on ZK Maven repository as they constitute what is known as Maven repository coordinates. For a complete list of all ZK library groupid and artifactid combinations please take a look at a sample pom.xml file that lists dependencies for all publically available ZK libraries on ZK Maven repository.
102
Sample of pom.xml
Here is sample pom.xml for a simple Java project that uses the ZK maven repository.
<?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>zk.app</groupId> <artifactId>MyZKMavenApp</artifactId> <version>0.0.1-SNAPSHOT</version> <repositories> <repository> <id>ZK CE</id> <name>ZK CE Repository</name> <url>http://mavensync.zkoss.org/maven2</url> </repository> <repository> <id>ZK EVAL</id> <name>ZK Evaluation Repository</name> <url>http://mavensync.zkoss.org/eval</url> </repository> </repositories> <dependencies> .... </dependencies> </project>
Sample of Dependencies
ZK CE
<dependencies> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkplus</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zhtml</artifactId> <version>6.0.0</version> </dependency>
Resolving ZK Framework Artifacts via Maven <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkbind</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zul</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> </dependencies>
103
ZK PE
<dependencies> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkplus</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zhtml</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkbind</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkex</artifactId>
Resolving ZK Framework Artifacts via Maven <version>6.0.0</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> </dependencies>
104
ZK EE
<dependencies> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkplus</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zhtml</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkbind</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>org.zkoss.zk</groupId> <artifactId>zkmax</artifactId> <version>6.0.0</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency>
Resolving ZK Framework Artifacts via Maven <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> </dependencies>
105
106
Resolving ZK Framework Artifacts via Maven </repository> <repository> <id>ZK EE</id> <url>https://maven.zkoss.org/repo/zk/ee</url> </repository> </repositories> Login authentication According to the official doc [9] of Apache Maven, users can create global settings for maven. Location (if not existed, you can create it manually) The Maven install: $M2_HOME/conf/settings.xml A user's install: ${user.home}/.m2/settings.xml Servers Element If you add ZK PE or ZK EE as your repository, you need to add login authentication like following example <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>ZK EE</id><!-- Same as your repository name --> <!-- Your premium user name and password --> <username>ryanwu</username> <password>2k055ecret</password> </server> </servers> </settings>
107
This will be helpful when you modify your dependencies of projects. 'Italic text'
108
Version History
Version Date Content
References
[1] [2] [3] [4] [5] [6] [7] [8] [9] http:/ / repo1. maven. org/ maven2 http:/ / mavensync. zkoss. org/ maven2 http:/ / www. zkoss. org/ services/ maven/ zk/ ?d=true& l=0& v=latest http:/ / www. zkoss. org/ services/ maven/ zk/ ?d=true& l=1& v=latest http:/ / www. zkoss. org/ services/ maven/ zk/ ?d=true& l=2& v=latest http:/ / www. zkoss. org/ services/ maven/ zk/ http:/ / www. zkoss. org/ product/ edition. dsp http:/ / www. sonatype. com/ books/ mvnref-book/ reference/ pom-relationships-sect-pom. html#pom-relationships-sect-super-pom http:/ / maven. apache. org/ settings. html#Servers
XML Editor
If you are using a XML editor, you could specify the schema directly in your ZUL document, such that the validation and Content Assist will be enabled automatically. Here is an example. <zk xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul/zul.xsd"> ... </zk> Notice that you have to specify the schema location in the root element, and the root element could be any valid ZUL component, such as window.
Version History
Version Date Content
109
110
111
112