ZK 5.0.4新特性
- Author
- Timothy Clare, Technology Evangelist, Potix Corporation
- Date
- August 31st, 2010
- Version
- ZK 5.0.4
ZK 5.0.4主要把焦点放在内存优化和引入一些新的特性上,除了内存有重大改善外, ZK 5.0.4 也引入许多新的特性,例如帧间通信, 新的水平垂直布局组件、像slider和combobox功能的提升
Contents[hide] |
内存优化
zk5.0.4 中,内存使用上有重大改善. 由对组件的测试来看,内存使用大约减少了40% 到 70% . 我们将sandbox application升级到zk 5.0.4 测试的时候,总计节约了63%的内存.
了解更多信息,请看测试结果ZK 5.0.4's memory improvements.
精炼的水平和垂直布局组件
引入两个新的组件Hlayout 和 Vlayout ,当布局控件的时候,它们给予开发者一个更加强大的选择. 在Vlayout 和 Hlayout的实现中, 我们使用 HTML Div 标签显示这两个布局组件的内容, 因此输出内容减少并且显示速度大约提高了两倍
了解更多信息,请看 ZK Component Reference: Hlayout, Vlayout, and Jumper Chen's blog: "Two new layout components in ZK 5.0.4, Hlayout and Vlayout".
命名快捷方式
ZK 5.0.4 引入命名空间快捷方式的概念,意思是说在写zul文件的时候,你无需指定完整的命名空间。例如:
<n:html xmlns:n="native"> <n:head> </n:head> </n:html>
For a complete list of namespace short cuts please click here.
echoEvent 支持任何对象类型
当前 叫 Events.echoEvent(String, Component, String)的函数 仅支持string 类型的数据. 然后, 从 ZK 5.0.4 开始,提供了一个新的函数Events.echoEvent(String, Component, Object) ,用于支持任意Object type,为开发者提供了更多的灵活性.
了解更多信息,请看 ZK Component Reference: Event Firing.
Slider 支持双击递增递减
ZK 5.0.4 引入了一个新的功能,允许用户双击期望的位置递增递减slider,.
<groupbox mold="3d" width="250px"> <caption label="Default" /> <slider id="slider1" onScroll="zoom(slider1, img1)" /> <image id="img1" src="/img/sun.jpg" width="10px" /> </groupbox>
Calendar 支持通过滑鼠移动上一月下一月
zk5.0.4增强功能的Calendar,可以滚动滑鼠改变月份, 就像出现在window里的功能
Radio 现在可以放在任意位置
在 ZK 5.0.4以前 Radio 组件 必须有一个 Radiogroup祖先. 现在 在 ZK 5.0.4中的 Radio可以放在任何位置
<radiogroup id="rg1"/> <radiogroup id="rg2"/> <grid width="300px"> <rows> <row> <radio label="radio 1.1" radiogroup="rg1"/> <radio label="radio 1.2" radiogroup="rg1"/> <radio label="radio 1.3" radiogroup="rg1"/> </row> <row> <radio label="radio 2.1" radiogroup="rg2"/> <radio label="radio 2.2" radiogroup="rg2"/> <radio label="radio 2.3" radiogroup="rg2"/> </row> </rows> </grid>
For more information please take a look at ZK Component Reference: Radiogroup.
Combobox 可选默认值
在 ZK 5.0.4,现在可以为combobox指定一个默认值. 下面这个例子演示如何设置默认值.
<combobox id="combobox" width="100px"> <attribute name="onCreate"><![CDATA[ List list2 = new ArrayList(); list2.add("David"); list2.add("Thomas"); list2.add("Steven"); ListModelList lm2 = new ListModelList(list2); lm2.addSelection(lm2.get(0)); combobox.setModel(lm2); ]]></attribute> </combobox>
lang.xml 中的widget class 支持 EL表达式
XML 中的widget class定义,现在支持EL表达式动态加载上下文环境中的widget classes.例如下面代码演示根据属性加载widget class.
<widget-class>${c:property("whatever")}</widget-class>
通过EL表达式的使用, 允许开发者根据不同用户不同条件提供不同主题的视图. 了解更多信息请看 Tom Yeh's blog post titled "Totally Different Look per User Without Modifying Application".
Button supports type="submit"
由于集成遗留应用的强烈需求,Button 现在支持submit 类型.
<n:form action="a_uri" xmlns:n="native"> <textbox/> <button type="submit" label="Submit"/> <button type="reset" label="Reset"/> </n:form>
合并多javascript文件
你可以通过将js文件合并成尽可能少的文件来加速网页的加载. 因此 ZK 5.0.4引入了简化文件合并的功能
注意js文件的合并可以通过 JSP, DSP 或者其他技术实现 ,该特性并不是唯一的实现方式. 本特性提供了一个 system-wide 的方式最大限度的减少js文件的数量.
了解更多信息请查看 ZK Developer's Guide: Performance Tip, and Jumper Chen's blog post titled "Speed up the loading time of a ZK Application".
无服务推送的帧间通信
在portal layout布局中,如果你的应用是一个多帧构成的多桌面程序,那么现在这些实例间通信可以不需要服务器推送技术或者定时器了,因此它可最大限度的减少网络流量
在ZK 5.0.4 中,引入了组的概念, 它用一个叫做group-scope事件队列使用实例间通信更加简单. 以下代码演示了一些例子:
EventQueue que = EventQueues.lookup("groupTest", "group", true); que.subscribe(new EventListener() { public void onEvent(Event evt) { o.setValue(o.getValue() + evt.getData() + "\n"); } }); void publish() { String text = i.getValue(); if (text.length() > 0) { i.setValue(""); que.publish(new Event("onGroupTest", null, text)); } }
了解更多信息请看 ZK Component Reference: Event Queues
This feature requires ZK EE
不维护服务器端状态最小化内存使用 (译者注:非常抱歉,收费版才可用,:( )
ZK 5.0.4 引入一个新的特性叫"存根唯一"的概念, 该功能输出客户端资源,但不维护服务器端状态, 由设置为boolean类型值的属性 「stubonly」控制, 当设置为 true时,zk将不维护服务器端状态
此属性由父类继承而来,因此将应用到父组件stubonly设置为true的所有子组件中. 请注意在唯一存根的组件已经显示之后,发送到客户端存根唯一的组件不可访问
下面演示存根唯一的功能. 请注意,在例子中 vbox, hbox, label 和 textbox 都是存根唯一的.
<window title="test of stub-only" border="normal"> <vbox stubonly="true"> <hbox> This is a label at Row 1, Cell 1. <textbox/> Another label at Row 1, Cell 2 (previous textbox is stub-only too) </hbox> <hbox> Another at Row 2, Cell 1 (and the following listbox is not stub-only) <listbox stubonly="false" width="50px"> <listitem label="item1"/> <listitem label="item2"/> </listbox> </hbox> </vbox> </window>
译者注:标记为stubonly的组件及子组件在服务器端将不可访问,例如<label id="lblName"/>,
在后端java code中你无法访问lblName,该功能为收费功能
了解更多信息请看 at ZK Developer's Guide: Performance Tip.
This feature requires ZK EE
Download & other resources
翻译如果有误请电邮 zhangxuehuaemail 在 gmail 点 com 或到http://sunflowers.iteye.com留言