Envisage ZK 6.0: Rendering List and Tree Model with Templates"

From Documentation
m
Line 14: Line 14:
  
 
=What Is Template=
 
=What Is Template=
 +
 +
A template is a segment of a  ZUML page enclosed with the <tt>template</tt> element as shown below.
 +
 +
<source lang="xml">
 +
<window>
 +
    <template name="foo">
 +
      <textbox/>
 +
      <grid>
 +
        <columns/>
 +
      </grid>
 +
  </template>
 +
...
 +
</source>
 +
 +
The template could contain any ZUML elements you want, even including another templates. When ZK interprets a template, ZK won't interpret its content immediately. Rather, it stores it as an instance of <tt>org.zkoss.zk.ui.util.Template</tt> into the component, such that it can be retrieved later to create components by the application or the component.
 +
 
=Listbox Model Rendering with Template=
 
=Listbox Model Rendering with Template=
 
=Grid Model Rendering with Template=
 
=Grid Model Rendering with Template=

Revision as of 10:00, 20 July 2011

DocumentationSmall Talks2011JulyEnvisage ZK 6.0: Rendering List and Tree Model with Templates
Envisage ZK 6.0: Rendering List and Tree Model with Templates

Author
Tom Yeh, Potix Corporation
Date
July 20, 2011
Version
ZK 5.1

WarningTriangle-32x32.png This page is under construction, so we cannot guarantee the accuracy of the content!

The Story

Before 5.1, the custom renderer must be implemented in Java. It is the most powerful since you could do anything with Java. However, in many cases, it is tedious since an additional Java class have to create and maintain and it is more about View than Control in MVC terminologies.

With 5.1, a concept called template is introduced. It allows UI designers to specify templates right in a ZUML page, and then the model can be rendered based on the template without any Java code.

What Is Template

A template is a segment of a ZUML page enclosed with the template element as shown below.

<window>
    <template name="foo">
      <textbox/>
      <grid>
         <columns/>
      </grid>
   </template>
...

The template could contain any ZUML elements you want, even including another templates. When ZK interprets a template, ZK won't interpret its content immediately. Rather, it stores it as an instance of org.zkoss.zk.ui.util.Template into the component, such that it can be retrieved later to create components by the application or the component.

Listbox Model Rendering with Template

Grid Model Rendering with Template

Tree Model Rendering with Template

Using Template in Application

Download

Comments



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