New Features of ZK 3.0.7"

From Documentation
m (correct highlight (via JWB))
 
Line 51: Line 51:
 
==New Features==
 
==New Features==
  
===<tt>Tree</tt> supports <tt>Paging</tt> mold.===
+
===<code>Tree</code> supports <code>Paging</code> 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.
 
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.
Line 86: Line 86:
  
  
===<tt>Image</tt> supports <tt>javax.awt.image.RenderedImage</tt>===
+
===<code>Image</code> supports <code>javax.awt.image.RenderedImage</code>===
  
 
ZK 3.0.7 allows image, button and related components to support RenderedImage directly without format conversion. Here is the example code,
 
ZK 3.0.7 allows image, button and related components to support RenderedImage directly without format conversion. Here is the example code,

Latest revision as of 04:16, 20 January 2022

DocumentationSmall Talks2008AugustNew Features of ZK 3.0.7
New Features of ZK 3.0.7

Author
Robbie Cheng, Engineer, Potix Corporation
Date
August 1, 2008
Version


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) {
		lb1.setValue(txt1.getValue());
	}
}


ZUL file,

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

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.

T1.png


1 node in the second page.

T2.png


Here is the example code,

<zscript>

	import org.zkoss.zkdemo.test2.tree.BinaryTreeModel;
	
	ArrayList al = new ArrayList();
	int i=0;
	for(; i < 100000; i++)
	{
		Object obj = ""+i;
		al.add(obj);
	}
	BinaryTreeModel btm = new BinaryTreeModel(al);
	
</zscript>
<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"/>
	<zscript>
	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.setColor(Color.blue);
		g2d.setStroke(new BasicStroke(3));
		g2d.draw(line);
		img.setContent(bi);
	}
	draw(x, y, x += 10, y += 10);
	</zscript>
	<button label="change" onClick="draw(x, y, x += 10, y += 10)"/>
</window>




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