ZK 6: Upgrade Notes

From Documentation
ZK 6: Upgrade Notes

Author
ZK Team, Potix Corporation
Date
November 15, 2011
Version
ZK 6

Overview

In additions to new features, ZK 6 also cleans up some API that are confusing, redundant or over complicated. The effort to upgrade depends on what features your application uses. Many of them shall run without modification. It is suggested to re-compile the applications and replace the code that use the deprecated API.

Upgrade addons

Here is a list of addons that you have to upgrade:

In additions, zcommons-el.jar is replaced with zel.jar for supporting EL 2.2. If you prefer EL 1.1 (i.e., backward compatible with ZK 5), please remove zel.jar and use zcommons-el.jar instead.

API that are changed

org.zkoss.zk.zul.api.* are removed

The component's API interfaces (org.zkoss.zk.ui.api.*, org.zkoss.zul.api.*...) are removed[1] Please replace them with the concrete classes. For example, use org.zkoss.zul.Window instead of org.zkoss.zul.api.Window.

Template:References

org.zkoss.zk.ui.util.Initiator is simplified

The org.zkoss.zk.ui.util.Initiator class now has only one method called doInit. The doAfterComposer, doCatch and doFinally methods are moved to org.zkoss.zk.ui.util.InitiatorExt. In other words, if you'd like to override any of these methods, your initiator has to implement both org.zkoss.zk.ui.util.Initiator and org.zkoss.zk.ui.util.InitiatorExt.

org.zkoss.xel.FunctionMapper is simplified

The getClassNames and resolveClass methods of the org.zkoss.xel.FunctionMapper class are removed. On the other hand, org.zkoss.xel.FunctionMapperExt was introduced to have these methods. In other words, you'd like to implement any of these methods, you have to implement both FunctionMapper and FunctionMapperExt.

API returns Iterable instead Iterator

To use with Java 5's for statement, the return type of the following APIs are changed to java.lang.Iterable:

  • org.zkoss.zk.ui.Exectuion: getHeaders and getHeaderNames
  • org.zkoss.zk.ui.WebApp: getInitParameterNames
  • org.zkoss.zk.ui.RichletConfig: getInitParameterNames

Window, Messagebox and Fileupload won't throw InterruptedException

Window, Messagebox and Fileupload won't throw java.lang.InterruptedException anymore, since it won't happen if the event processing thread is disabled (default). If the event processing thread is enabled, InterruptedException will be wrapped with UiException.

addEventListener allows the same listener registered multiple times

Component's addEventListener now allows the same listener being registered multiple times, and the listener will be called multiple times.

If you prefer to ignore the second registration of the same listener (i.e., backward compatible with ZK 5 and earlier), you could specify a library property called org.zkoss.zk.ui.EventListener.duplicateIgnored to true in WEB-INF/zk.xml.

UiFactory's newComponent is changed

The newComponent method of the org.zkoss.zk.ui.sys.UiFactory is changed. In additions, two new methods newComposer and newServerPush were introduced to allow developers have more control of the instantiations.

GenericForwardComposer and GenericAutowireComposer won't wire variables defined in zscript and variable resolvers

For sake of better performance, org.zkoss.zk.ui.util.GenericForwardComposer and org.zkoss.zk.ui.util.GenericAutowireComposer won't wire variables defined in zscript and variable resolvers. If you prefer to write them as ZK 5 and earlier does, you could specify the library properties called org.zkoss.zk.ui.composer.autowire.zscript and org.zkoss.zk.ui.composer.autowire.xel to true.

Component's newChildren and newExtraCtrl are removed

The newChildren and newExtraCtrl methods of AbstractComponent are removed. Please override the getChildren and getExtraCtrl instead.

Component's setVariable is removed

Component's setVariable method is removed. Please use Component.setAttribute(name, value, SPACE_SCOPE) instead. In other words, you could store the variables in the attributes of the space owner (Component.getSpaceOwner()).

ListX, TreeArray and CheckableTreeArray are removed

The org.zkoss.util.ListX, org.zkoss.util.TreeArray and org.zkoss.util.CheckableTreeArray are removed. Please use java.util.LinkedList or java.util.ArrayList instead.

API that are deprecated

org.zkoss.zul.SimpleTreeModel and org.zkoss.zul.SimpleTreeNode are deprecated

The org.zkoss.zul.SimpleTreeModel and org.zkoss.zul.SimpleTreeNode classes are deprecated and replaced with org.zkoss.zul.DefaultTreeModel and org.zkoss.zul.DefaultTreeNode.

Notice the previous classes are still available but deprecated (not found in JavaDoc).

org.zkoss.zk.ui.event.Expression is deprecated

The org.zkoss.zk.ui.event.Expression interface is deprecated. Please use the addEventListener(int, String, EventListener) method instead, and assign the priority as 1000.

HTMLs, StyleSheet and JavaScript are moved

The HTMLs, StyleSheet and JavaScript classes are moved to the package called org.zkoss.html.

Notice the previous classes are still available but deprecated (not found in JavaDoc).

Theme and UI

Breeze is the default theme

The breeze theme has become the default styling, without the need to include breeze.jar. Please make sure you remove breeze.jar from your project. On the other hand, the sapphire and silvertail themes are packaged and delivered as they were in ZK 5. Of course, you have to upgrade to the version shipped with ZK 6's binary distribution.

Messagebox's template is changed

Messagebox's template (i.e., ~./zul/html/messagebox.zul) is changed. If you ever customized it, please refer to the source code for the details.

Groupbox's zclass is renamed to z-groupbox

The zclass of Groupbox's default mold is renamed to z-groupbox(it was called z-fieldset in ZK 5). The zclass of the 3d mold is renamed to z-groupbox-3d (it was called z-groupbox).

The vflex and hflex of Panelchildren are deprecated

The hflex/vflex properties of Panelchildren are determined by its parent Panel's hflex/vflex properties. The setHflex and setVflex methods of Panelchildren will throw UnsupportedOperationException. In other words, you shall control Panel rather than Panelchildren.

The hflex and width of Treerow, Rows... is deprecated

As the sizing of Grid/Listbox/Tree are controlled by Grid/Listbox/Tree and the header components (such as Treecol, Listheader and Column). By others, the hflex and width properties of them are irrelevant. Their setHflex and setWidth methods are deprecated. These components include: Treeitem, Treerow, Treecell, Treechildren, Treecols, Treefoot, Rows, Columns, Row, Cell, Foot, Listitem, Listcell, Listhead, Listfoot.


Comments



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


  1. The reason to remove them is they cause more confusion than the abstraction benefit, and they are costly to maintain.