Java AJAX开发系列 - 3, ZK MVC

MVC架构在现在的很多系统中都有使用,ZK中同样也可以使用这种模式,如下是具体的例子:

View

<window id="win" title="ZK Essentials" border="normal" width="250px" apply="demo.zkoss.SampleCtrl">

<listbox id="orderLibox"

model="@{orderArea$composer.orders}" selectedItem="@{selectedX}">

<listhead>

<listheader label="info" />

<listheader label="description" />

<listheader label="Sub Total" />

</listhead>

<listitem self="@{each='order'}" value="@{order}">

<listcell

label="@{order, converter='demo.web.ui.OrderInfoTypeConverter'}" />

<listcell label="@{order.description}" />

<listcell label="@{order.total}" />

</listitem>

</listbox>

<button id="helloBtn" label="Hello"/>

</window>

Controller

package demo.zkoss;

import org.zkoss.zk.ui.util.GenericForwardComposer;

import org.zkoss.zul.Button;

import org.zkoss.zul.Window;

public class SampleCtrl extends GenericForwardComposer {

Window win;

public void onClick$helloBtn(){

Button btn = new Button();

btn.setLabel("World !");

btn.setParent(win);

}

public List<Order> getOrders() {

List<Order> orders = getOrderDAO().findByUser(getCurrentUserId());

return orders;

}

}

Model

Order就是Model对象

 

ZK 5 Essentials 书中例子就包含了这方面的内容:

https://skydrive.live.com/?cid=56b433ad3d1871e3&id=56B433AD3D1871E3%21265

以上是完整工程下载,

 

posted @   2012  阅读(670)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示