Java AJAX開發系列 – 3, ZK MVC

來源:互聯網
上載者:User
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

以上是完整工程下載,

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.