New Features of ZK 3.0.7

From Documentation
DocumentationSmall Talks2008AugustNew Features of ZK 3.0.7
New Features of ZK 3.0.7

Robbie Cheng, Engineer, Potix Corporation
August 1, 2008

ZK 3.0.7 focuses mainly on fixing bugs. In addition to over 22 bug fixes, there are 9 new features.

These new features include component enhancement, and ease-of-use utilities. For example, Tree supports paging mold, which is more convenient and useful. An easier way to forward event in Java files. And from now on, Image accepts javax.awt.image.RenderedImage.

In the following paragraphs, I'll introduce the most exciting new additions to ZK 3.0.7.

Ease of Use

A more convenient way to forward events in Java

Before ZK 3.0.7, develoeprs used to write forward attribute in ZUL files. Here comes another option which makes the UI even cleaner. Developers are allowed to forward events in Java files directly with the help of GenericForwardComposer as follows,

Java file,

public class MyComposer extends GenericForwardComposer{
	private txt1;
	private lb1;

	public void onChange$txt1(Event evt) {

ZUL file,

<window id="mywin" apply="MyComposer">
	<textbox id="txt1"/>
	<label id="lb1"/>

There is no need to write forward in since GenericForwardComposer will add the forward for you as long as you write your eventlistener in the form of onXxx$id. Here the example (onChange$txt1) says forward onChange event from txt1 to the applied component.

Component Reloaded

New Features

Tree supports Paging mold.

ZK 3.0.7 enhance Tree to support paging mold, and Tree supports individual or external Paging component. The major difference lies in the pagination of the tree which is based on the total number of visible tree items instead of the tree children of certain treeitem. For example, if the page size is 5, and the user can see 6 nodes, there will be 2 pages.

5 nodes in the first page.


1 node in the second page.


Here is the example code,


	import org.zkoss.zkdemo.test2.tree.BinaryTreeModel;
	ArrayList al = new ArrayList();
	int i=0;
	for(; i < 100000; i++)
		Object obj = ""+i;
	BinaryTreeModel btm = new BinaryTreeModel(al);
<tree  model="${btm}" id="tree" mold="paging" pageSize="5">

Image supports javax.awt.image.RenderedImage

ZK 3.0.7 allows image, button and related components to support RenderedImage directly without format conversion. Here is the example code,

<window title="Test of Live Image">
	<image id="img"/>
	import java.awt.*;
	import java.awt.image.*;
	import java.awt.geom.*;
	int x = 10, y = 10;

	void draw(int x1, int y1, int x2, int y2) {
		BufferedImage bi = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB);
		Graphics2D g2d = bi.createGraphics();
		Line2D line = new Line2D.Double(x1, y1, x2, y2);
		g2d.setStroke(new BasicStroke(3));
	draw(x, y, x += 10, y += 10);
	<button label="change" onClick="draw(x, y, x += 10, y += 10)"/>

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