ZK 3.6.3 with Netbeans 6.8 Beta on Glassfish V3

I am using Netbeans 6.8B for a few days and mainly testing if my existing JEE5 projects can be opened, deployed and executed on GF3. I am using ZK as Web/Ajax Framework. Usually the ZK team releases a new NB plugin to help you to create ZK based Java Web projects. Currently the plugin supports 3.6.2, some days back ZK 3.6.3 was released, so I guess in a few days time we will have a 3.6.3 plugin. The plugin creates a skeleton for a JEE5 webproject and I doubt they will support Java EE6 before EE6 is finally released (December?).

I was curious to see if I get the latest ZK running on GF V3 as a JEE6 application.

Part 1: ZK 3.6.2 with Netbeans 6.8B as EE5 Web Project

First, lets try first to add the 3.6.2. plugin to NB 6.8B

SVH20091105_001

ZK plugin 3.6.2

Create a new Java Web Project with ZK (under EE5)

Create ZK project (EE5)

Create ZK project (EE5)

f

Create ZK project (EE5)

Project successfully created with all settings as expected.

SVH20091105_004

ZK Web Project Properties

SVH20091105_005

ZK Web Project Properties

Build, Deploy and Run the project.

SVH20091105_006

Deploying and Running ZK Web project (EE5) in GF V3

That, looks fine. Lets see what the plugin actually does, when you create a new project. It adds the library (project properties) and insert some lines to the web.xml file.

project.properties

..
j2ee.deploy.on.save=true
j2ee.platform=1.5
j2ee.server.type=gfv3ee6
jar.compress=false
javac.classpath=\
 ${libs.ZK3.6.2.classpath}:\
 ${libs.hibernate-support.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
..

web.xml

..
<!-- //// -->
 <!-- ZK -->
 <listener>
 <description>ZK listener for session cleanup</description>
 <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
 </listener>
 <servlet>
 <description>ZK loader for ZUML pages</description>
 <servlet-name>zkLoader</servlet-name>
 <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
 <!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet).
 It must be the same as <url-pattern> for the update engine.
 -->
 <init-param>
 <param-name>update-uri</param-name>
 <param-value>/zkau</param-value>
 </init-param>
 <!-- Optional. Specifies whether to compress the output
 of the ZK loader. It speeds up the transmission over slow Internet.
 However, if you configure a filter to post-processing the
 output, you might have to disable it.

 Default: true
 <init-param>
 <param-name>compress</param-name>
 <param-value>true</param-value>
 </init-param>
 -->
 <!-- Optional. Specifies the default log level: OFF, ERROR, WARNING,
 INFO, DEBUG and FINER. If not specified, the system default is used.
 <init-param>
 <param-name>log-level</param-name>
 <param-value>OFF</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>*.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>

 <!-- Optional. Uncomment it if you want to use richlets.
 -->
 <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>

 <!-- [Optional] Specifies the AU processor for particular prefix.
 <init-param>
 <param-name>processor0</param-name>
 <param-value>/upload=com.my.MyUploader</param-value>
 </init-param>
 -->
 </servlet>
 <servlet-mapping>
 <servlet-name>auEngine</servlet-name>
 <url-pattern>/zkau/*</url-pattern>
 </servlet-mapping>

 <!-- Uncomment if you want to use the ZK filter to post process the HTML output
 generated by other technology, such as JSP and velocity.
 <filter>
 <filter-name>zkFilter</filter-name>
 <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class>
 <init-param>
 <param-name>extension</param-name>
 <param-value>html</param-value>
 </init-param>
 <init-param>
 <param-name>compress</param-name>
 <param-value>true</param-value>
 </init-param>
 </filter>
 <filter-mapping>
 <filter-name>zkFilter</filter-name>
 <url-pattern>/test/filter.dsp</url-pattern>
 </filter-mapping>
 <filter-mapping>
 <filter-name>zkFilter</filter-name>
 <url-pattern>/test/filter2.dsp</url-pattern>
 </filter-mapping>
 -->

 <!-- ///////////// -->
 <!-- DSP (optional) -->
 <!-- We need it to show zkdemo correctly (due to categorybar.dsp)
 -->
 <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-mapping>
 <servlet-name>dspLoader</servlet-name>
 <url-pattern>*.dsp</url-pattern>
 </servlet-mapping>

 <!-- /////////// -->
..

This changes we need to apply if we create a Web project without plugin support.

Part 2: Add ZK 3.6.3 manually to Netbeans as Global Library

In the absence of the plugin (which certainly comes soon) we manually add ZK3.6.3 to Netbeans. I recommend to have the 3.6.2 plugin installed, so we can user the new zul page create assitant. After downloading the release 3.6.3 from the www.zkoss.org we need to create the same structure as for 3.6.2 in the local .netbeans directory. Create a directory zk363.

SVH20091106_017

.netbeans directory structure

Unzip the ZK bin file and copy all jar files (from the different folders under lib) into the new directory zk363. No other files or directories in that folder.

SVH20091106_018

Content of the ZK3.6.3 release (zk-bin-3.6.3)

Now start Netbeans and open the Library Manager (Tools|Libraries) and ‘Add New Library’, name it ZK3.6.3 and add the complete folder from above.

SVH20091106_013

Create Global Library ZK3.6.3

SVH20091106_014

Create Global Library

Now you can add ZK 3.6.3 to any of your web projects.

Part 3: Create EE6 Web Project

Lets create a new JEE6 web project using the just created ZK3.6.3 Library.

SVH20091105_007

New Web Project

SVH20091105_008

New Web Project

SVH20091105_009

New Web Project

Add the global library.

SVH20091106_016

Add ZK3.6.3 Library

First problem: Since we dont have the plugin doing the configuration for us we need to copy the required entries manually (you can copy the complete fragment from the above web.xml).

Second problem: JEE6 works without web.xml, but we still can create and use it.

SVH20091106_007

Create web.xml

SVH20091106_008

Create web.xml

x

web.xml skeleton

Add the above zk configuration and we have a web.xml like this:

<?xml version="1.0" encoding="UTF-8"?>

<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_3_0.xsd"
 version="3.0">
 <session-config>
 <session-timeout>
 30
 </session-timeout>
 </session-config>

<!-- //// -->
 <!-- ZK -->
 <listener>
 <description>ZK listener for session cleanup</description>
 <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
 </listener>
 <servlet>
 <description>ZK loader for ZUML pages</description>
 <servlet-name>zkLoader</servlet-name>
 <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
 <!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet).
 It must be the same as <url-pattern> for the update engine.
 -->
 <init-param>
 <param-name>update-uri</param-name>
 <param-value>/zkau</param-value>
 </init-param>
 <!-- Optional. Specifies whether to compress the output
 of the ZK loader. It speeds up the transmission over slow Internet.
 However, if you configure a filter to post-processing the
 output, you might have to disable it.

 Default: true
 <init-param>
 <param-name>compress</param-name>
 <param-value>true</param-value>
 </init-param>
 -->
 <!-- Optional. Specifies the default log level: OFF, ERROR, WARNING,
 INFO, DEBUG and FINER. If not specified, the system default is used.
 <init-param>
 <param-name>log-level</param-name>
 <param-value>OFF</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>*.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>

 <!-- Optional. Uncomment it if you want to use richlets.
 -->
 <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>

 <!-- [Optional] Specifies the AU processor for particular prefix.
 <init-param>
 <param-name>processor0</param-name>
 <param-value>/upload=com.my.MyUploader</param-value>
 </init-param>
 -->
 </servlet>
 <servlet-mapping>
 <servlet-name>auEngine</servlet-name>
 <url-pattern>/zkau/*</url-pattern>
 </servlet-mapping>

 <!-- Uncomment if you want to use the ZK filter to post process the HTML output
 generated by other technology, such as JSP and velocity.
 <filter>
 <filter-name>zkFilter</filter-name>
 <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class>
 <init-param>
 <param-name>extension</param-name>
 <param-value>html</param-value>
 </init-param>
 <init-param>
 <param-name>compress</param-name>
 <param-value>true</param-value>
 </init-param>
 </filter>
 <filter-mapping>
 <filter-name>zkFilter</filter-name>
 <url-pattern>/test/filter.dsp</url-pattern>
 </filter-mapping>
 <filter-mapping>
 <filter-name>zkFilter</filter-name>
 <url-pattern>/test/filter2.dsp</url-pattern>
 </filter-mapping>
 -->

 <!-- ///////////// -->
 <!-- DSP (optional) -->
 <!-- We need it to show zkdemo correctly (due to categorybar.dsp)
 -->
 <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-mapping>
 <servlet-name>dspLoader</servlet-name>
 <url-pattern>*.dsp</url-pattern>
 </servlet-mapping>

 <!-- /////////// -->

</web-app>

Finally we create a new zul page (New File..|Web|ZK/zkcanvas)

SVH20091106_019

New File

SVH20091106_020

Name

SVH20091106_021

index.zul

Drag and drop any of the controls (better one that does not require further programming, like the Date picker) and drop it into the zul page.

Deploy and run it. Voila !

SVH20091106_022

index.zul with datepicker in the browser

About these ads

5 thoughts on “ZK 3.6.3 with Netbeans 6.8 Beta on Glassfish V3

  1. Thanks.

    A quick question: does it support “content assist” or “code assist”? It will be a great help for editing the zul file.

  2. Yes, when editing the zul file you have the code completion feature while creating tags like (button id=”some_id” action=””..) , but no code completion when you place script or code inside zul files, eg. using the zscript tag. I recommend to separate zul files from logic by creating a controller (java) class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s