New Features of ZK 6.5.1"

From Documentation
m (correct highlight (via JWB))
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Template:Smalltalk_Author|
 
{{Template:Smalltalk_Author|
 
|author=Timothy Clare, Potix Corporation
 
|author=Timothy Clare, Potix Corporation
|date=December 4, 2012
+
|date=December 05, 2012
 
|version=ZK 6.5.1
 
|version=ZK 6.5.1
 
}}
 
}}
 +
 +
==Introduction==
 +
 +
ZK 6.5.1 concentrates on fixing bugs and introducing a few new features including a default command for MVVM, page visibility with HTML 5 API and others.
 +
 +
ZK 6.5 series focuses on taking developers to achieve real device transparency in one codebase and component set, exploring the area of combined desktop & tablet UI and touch experiences. Introducing responsive design and responsive components to always fit your device screen resolution and tablet-specific user interaction methods such as swiping and device orientation detection which are done automatically to save developers time, effort and to increase massive productivity.
  
 
=The Default Command for MVVM=
 
=The Default Command for MVVM=
 +
{{ZK All}}
  
 
ZK 6.5.1 brings a default command for MVVM. When a binder receives a command, it starts to find ViewModel's command methods by matching its name. If the binder cannot find a matched method, it invokes default command method.  
 
ZK 6.5.1 brings a default command for MVVM. When a binder receives a command, it starts to find ViewModel's command methods by matching its name. If the binder cannot find a matched method, it invokes default command method.  
Line 11: Line 18:
 
Assume that there are only two command methos in the below ViewModel. If we trigger a command "exit", a binder invokes the default command method defaultAction() because it cannot find a command method named "exit".  
 
Assume that there are only two command methos in the below ViewModel. If we trigger a command "exit", a binder invokes the default command method defaultAction() because it cannot find a command method named "exit".  
  
<source lang="java" high="8">
+
<source lang="java" highlight="8">
 
public class OrderVM {
 
public class OrderVM {
  
Line 27: Line 34:
  
 
=Control Page visibility with HTML 5 API in ZK=
 
=Control Page visibility with HTML 5 API in ZK=
 +
{{ZK All}}
 +
 +
In order to develop power and CPU efficient web applications, W3C publishes a specification named Page Visibility in HTML 5 which defines a means for site developers to programmatically determine the current visibility state of the page. In this specification, there are two attributes defined: hidden and visibilityState, where hidden is a boolean value representing whether the current page is visible or not and visibilityState represents that the current page have four states: hidden, visible, prerender, and unloaded.
  
 
In ZK 6.5.1, the API with onVisibilityChange event was implemented which provides the ability to find out when a page is visible or hidden. This has a lot of benefit as it enables saving of CPU cycles as well as bandwidth. The following is a very simple example:
 
In ZK 6.5.1, the API with onVisibilityChange event was implemented which provides the ability to find out when a page is visible or hidden. This has a lot of benefit as it enables saving of CPU cycles as well as bandwidth. The following is a very simple example:
  
<pre lang="xml">
+
<source lang="xml">
 
<window title="window" border="normal">
 
<window title="window" border="normal">
 
     <attribute name="onVisibilityChange">
 
     <attribute name="onVisibilityChange">
Line 38: Line 48:
 
     <label id="lbl"></label>
 
     <label id="lbl"></label>
 
</window>
 
</window>
</pre>
+
</source>
 +
 
 +
For more information please check the blog post [http://blog.zkoss.org/index.php/2012/12/02/control-page-visibility-with-html5-api-in-zk/ here] and the [[ZK_Developer's_Reference/UI_Patterns/Browser_Information_and_Control#Browser_Page_Visibility_State | ZK Developer's Reference]].
 +
 
 +
==Comet Server push support==
 +
 
 +
{{ZK PE and EE}}
 +
 
 +
The visibility functionality has also been extended to comet server push to reduce the server loading by default.
 +
 
 +
=Messagebox without buttons=
 +
{{ZK All}}
  
For more information please check the blog post [http://blog.zkoss.org/index.php/2012/12/02/control-page-visibility-with-html5-api-in-zk/ here].
+
With ZK 6.5.1 if you'd like to show a non-buttons dialog, you can use <javadoc method="show(java.lang.String, org.zkoss.zul.Messagebox.Button[], org.zkoss.zk.ui.event.EventListener listener)">org.zkoss.zul.Messagebox</javadoc> with an empty array as follows.
  
 +
<source lang="java">
 +
Messagebox.show("Cancel the operation?",
 +
new Messagebox.Button[0], null);
 +
</source>
 +
 +
This messagebox will show without any buttons.
 +
 +
=DefaultTreeNode - empty node now can be treated as a leaf node=
 +
{{ZK All}}
 +
 +
In ZK 6.5.1 <javadoc>org.zkoss.zul.DefaultTreeModel</javadoc> provides a boolean argument to its constructor for configuring to treat the zero size of children node as a leaf node.
 +
 +
<source lang="java">
 +
//@param emptyChildAsLeaf whether to treat the zero size of children node as a leaf node.
 +
DefaultTreeModel model2 = new DefaultTreeModel(root, true);
 +
</source>
 +
 +
For more information please refer to [[ZK_Developer's_Reference/MVC/Model/Tree_Model | ZK's Developer's Reference]].
  
 
=Download & other resources=
 
=Download & other resources=
Line 48: Line 87:
 
*[http://www.zkoss.org/product/zk/releasenote/6.5.1 Take a look at ZK 6.5.1's release notes here]
 
*[http://www.zkoss.org/product/zk/releasenote/6.5.1 Take a look at ZK 6.5.1's release notes here]
  
 
+
[[Category:New Features]]
 
{{Template:CommentedSmalltalk_Footer|
 
{{Template:CommentedSmalltalk_Footer|
 
|name=Potix Corporation
 
|name=Potix Corporation
 
}}
 
}}

Latest revision as of 04:19, 20 January 2022

DocumentationSmall Talks2012DecemberNew Features of ZK 6.5.1
New Features of ZK 6.5.1

Author
Timothy Clare, Potix Corporation
Date
December 05, 2012
Version
ZK 6.5.1

Introduction

ZK 6.5.1 concentrates on fixing bugs and introducing a few new features including a default command for MVVM, page visibility with HTML 5 API and others.

ZK 6.5 series focuses on taking developers to achieve real device transparency in one codebase and component set, exploring the area of combined desktop & tablet UI and touch experiences. Introducing responsive design and responsive components to always fit your device screen resolution and tablet-specific user interaction methods such as swiping and device orientation detection which are done automatically to save developers time, effort and to increase massive productivity.

The Default Command for MVVM

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ce-pe-ee.png

ZK 6.5.1 brings a default command for MVVM. When a binder receives a command, it starts to find ViewModel's command methods by matching its name. If the binder cannot find a matched method, it invokes default command method.

Assume that there are only two command methos in the below ViewModel. If we trigger a command "exit", a binder invokes the default command method defaultAction() because it cannot find a command method named "exit".

public class OrderVM {

    @Command
    public void newOrder(){
    ...
    }
  
    @DefaultCommand
    public void defaultAction(){
    ...
    }
}

Control Page visibility with HTML 5 API in ZK

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ce-pe-ee.png

In order to develop power and CPU efficient web applications, W3C publishes a specification named Page Visibility in HTML 5 which defines a means for site developers to programmatically determine the current visibility state of the page. In this specification, there are two attributes defined: hidden and visibilityState, where hidden is a boolean value representing whether the current page is visible or not and visibilityState represents that the current page have four states: hidden, visible, prerender, and unloaded.

In ZK 6.5.1, the API with onVisibilityChange event was implemented which provides the ability to find out when a page is visible or hidden. This has a lot of benefit as it enables saving of CPU cycles as well as bandwidth. The following is a very simple example:

<window title="window" border="normal">
    <attribute name="onVisibilityChange">
        if (!event.isHidden())
            lbl.setValue("Welcome back");
    </attribute>
    <label id="lbl"></label>
</window>

For more information please check the blog post here and the ZK Developer's Reference.

Comet Server push support

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion pe-ee.png

The visibility functionality has also been extended to comet server push to reduce the server loading by default.

Messagebox without buttons

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ce-pe-ee.png

With ZK 6.5.1 if you'd like to show a non-buttons dialog, you can use Messagebox.show(String, Button[], EventListener listener) with an empty array as follows.

 Messagebox.show("Cancel the operation?",
 	new Messagebox.Button[0], null);

This messagebox will show without any buttons.

DefaultTreeNode - empty node now can be treated as a leaf node

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ce-pe-ee.png

In ZK 6.5.1 DefaultTreeModel provides a boolean argument to its constructor for configuring to treat the zero size of children node as a leaf node.

//@param emptyChildAsLeaf whether to treat the zero size of children node as a leaf node.
DefaultTreeModel model2 = new DefaultTreeModel(root, true);

For more information please refer to ZK's Developer's Reference.

Download & other resources

Comments



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