jasmine214--love

          只有當(dāng)你的內(nèi)心總是充滿快樂、美好的愿望和寧靜時,你才能擁有強壯的體魄和明朗、快樂或者寧靜的面容。
          posts - 731, comments - 60, trackbacks - 0, articles - 0
          ?
          原文:http://chanson.javaeye.com/blog/164786
          1、Spring+Hibernate配置起來很簡單,具體就不細(xì)說了,網(wǎng)上多的是。

          2、ZK顯示頁面
          【query.zul】
          <?xml version="1.0" encoding="UTF-8"?>
          <window>
          <button label="查詢"></button>
          <vbox>
          ? <listbox id="testListID" width="800px" rows="5" use="chanson.common.web.ui.ListTestBean">
          ??? <listhead>
          ????? <listheader label="姓名"/>
          ????? <listheader label="性別"/>
          ????? <listheader label="生日"/>
          ????? <listheader label="薪資"/>
          ??? </listhead>
          ??? <listitem value="${each.id}" forEach="${testList}">
          ????? <listcell label="${each.name}"/>
          ????? <listcell label="${each.sex}"/>
          ????? <listcell label="${each.birthday}"/>
          ????? <listcell label="${each.money}"/>
          ??? </listitem>
          ? </listbox>
          </vbox>
          </window>

          《說明》:
          A、<?xml version="1.0" encoding="UTF-8"?>
          這個別忘記了,剛學(xué)的時候就是因為它報了不少錯誤。
          B、use="chanson.common.web.ui.ListTestBean"
          這個類就是銜接前后臺的關(guān)鍵類。
          C、${*.*}這個是標(biāo)準(zhǔn)的EL寫法。


          3、ListTestBean——最關(guān)鍵的銜接類
          public class ListTestBean extends Listbox {

          ??? public void onCreate() {
          ??? ? ITestLogic testLogic = (ITestLogic) SpringFactory
          ? .getBeanFactory().getBean("testLogic");
          ??? ? List testList = testLogic.find("from Test");
          ??????? Iterator it = testList.iterator();
          ??????? while(it.hasNext()) {
          ??????????? Test test = (Test) it.next();
          ??????????? Long id = test.getId();
          ??????????? String name = test.getName();
          ??????????? Integer sex = test.getSex();
          ??????????? Date birthday =test.getBirthday();
          ??????????? Double money = test.getMoney();??????

          ??????????? Listitem listitem = new Listitem();
          ??????????? listitem.setValue(id);
          ??????????? listitem.setParent(this);

          ??????????? Listcell nameCell = new Listcell(name);
          ??????????? Listcell sexCell = new Listcell(sex.toString());
          ??????????? Listcell birthdayCell = new Listcell(birthday.toString());
          ??????????? Listcell moneyCell = new Listcell(money.toString());
          ??????????? nameCell.setParent(listitem);
          ??????????? sexCell.setParent(listitem);
          ??????????? birthdayCell.setParent(listitem);
          ??????????? moneyCell.setParent(listitem);
          ??????? }
          ???? }
          }
          《說明》:
          A、例子是一個簡單的查詢,所以看起來也比較簡單。
          B、該類的作用有點像似servlet,只是省略了頁面跳轉(zhuǎn)
          C、setter/getter真是麻煩,得找找更簡潔的方法



          【附錄】
          1)、數(shù)據(jù)庫設(shè)計——test表
          CREATE TABLE `test` (
          ? `id` decimal(22,0) NOT NULL default '0',
          ? `name` varchar(100) default NULL,
          ? `sex` int(1) default NULL,
          ? `birthday` datetime default NULL,
          ? `money` decimal(15,4) default NULL,
          ? PRIMARY KEY? (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
          2)、其他應(yīng)該沒什么了吧?
          3)、頁面效果圖
          • 描述: 頁面效果圖
          • 大小: 27.5 KB
          主站蜘蛛池模板: 龙海市| 丹寨县| 新乐市| 乐业县| 晴隆县| 普安县| 霍林郭勒市| 左权县| 丰县| 德州市| 南漳县| 兴安县| 永川市| 吴旗县| 中江县| 安龙县| 平果县| 洛阳市| 汕头市| 宁国市| 印江| 新宾| 涟源市| 武夷山市| 锡林郭勒盟| 大田县| 元氏县| 乐业县| 中宁县| 宜章县| 延边| 舒城县| 玉溪市| 沛县| 广东省| 南江县| 康马县| 昌平区| 通河县| 昔阳县| 黑河市|