Packing Code

From Documentation

There are two ways to pack the customization code: part of the Web application, or an independent JAR file. Packing as part of the Web application is straightforward. All you have to do is to specify the customization in WEB-INF/zk.xml as described in ZK Configuration Reference.

In many cases, it is better to pack the customization code as an independent JAR file, such that it can be managed separately, and reused in multiple Web applications.

Where to Configure a JAR File

The configuration of a JAR file can be placed in a file called config.xml, and it must be under /metainfo/zk. If the JAR file also provides the component definitions, you have to prepare another fiile called lang-addon.xml under the same directory[1].

The content of /metainfo/zk/config.xml is similar to WEB-INF/zk.xml, except only a subset of configurations are allowed. Here is a sample (zkex.jar 's config.xml)[2]:

<config>
	<config-name>zkex</config-name><!-- used to resolve dependency -->
	<depends>zk</depends>

	<version>
		<version-class>org.zkoss.zkex.Version</version-class>
		<version-uid>5.0.6</version-uid>
		<zk-version>5.0.0</zk-version><!-- or later -->
	</version>

	<listener>
		<listener-class>org.zkoss.zkex.init.WebAppInit</listener-class>
	</listener>

	<library-property>
		<name>org.zkoss.zul.chart.engine.class</name>
		<value>org.zkoss.zkex.zul.impl.JFreeChartEngine</value>
	</library-property>
	<library-property>
		<name>org.zkoss.zul.captcha.engine.class</name>
		<value>org.zkoss.zkex.zul.impl.JHLabsCaptchaEngine</value>
	</library-property>
</config>

  1. For more information, please refer to ZK Client-side Reference: Language Definition.
  2. For more information, please refer to ZK Configuration Reference: JAR File's config.xml.

How to Initialize a JAR File

Version History

Last Update : 2010/12/21


Version Date Content
     



Last Update : 2010/12/21

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.