日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

java生成j动态页面_zk动态产生多个页面的例子代码

發(fā)布時(shí)間:2025/3/15 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java生成j动态页面_zk动态产生多个页面的例子代码 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

/**

*

* @功能 添加參數(shù)

* @author 創(chuàng)建人 gao_jie

* @date 創(chuàng)建日期 Apr 23, 2009

* @version 1.0

*

*/

public class AddParameter extends Window implements AfterCompose {

private static final long serialVersionUID = 1L;

private int num = 0;// 條件個(gè)數(shù)

private Window win;// 參數(shù)風(fēng)格

private Rows parameterRows;// 條件行數(shù)

private DesignerWnd desiWnd = null;

@SuppressWarnings("unused")

private Spreadsheet spreadSheet;

private InforReport inforreport;

/*

* (non-Javadoc)

*

* @see org.zkoss.zk.ui.ext.AfterCompose#afterCompose()

*/

public void afterCompose() {

parameterRows = (Rows) this.getFellow("parameterRows");

win = (Window) this.getFellow("AddParameter");

desiWnd = (DesignerWnd) Sessions.getCurrent().getAttribute("dWnd");

spreadSheet = (Spreadsheet) desiWnd.getFellow("spreadSheet");

inforreport = spreadSheet.getReport();

this.initiPage(inforreport.getParameters());

}

/**

* 初始化參數(shù)頁(yè)面 獲取已定義的參數(shù) 現(xiàn)實(shí)參數(shù)的name,type,defaultValue并可改

*

* @param Parameters

*/

@SuppressWarnings("unchecked")

public void initiPage(Map Parameters) {

parameterRows.getChildren().clear();

if (Parameters != null && !Parameters.isEmpty()) {

// 遍歷Parameters的鍵集

Set parametset = Parameters.keySet();

Iterator ir = parametset.iterator();

while (ir.hasNext()) {

String key = (String) ir.next();

// 獲取已有的每一個(gè)參數(shù)

Parameter parameter = (Parameter) Parameters.get(key);

// 計(jì)數(shù)器+1

num = num + 1;

// 為每個(gè)參數(shù)在parameterRows里創(chuàng)建一個(gè)Row

Row row = new Row();

row.setId("row_" + num);

row.setParent(parameterRows);

// 每個(gè)Row添加一個(gè)name,賦值為當(dāng)前獲取參數(shù)的name

Textbox name = new Textbox();

name.setId("name_" + num);

name.setWidth("80px");

name.setValue(parameter.getName());

name.setParent(row);

// 每個(gè)Row添加一個(gè)type,賦值為當(dāng)前獲取參數(shù)的type

Listbox type = new Listbox();

type.setParent(row);

type.setId("type_" + num);

type.setMold("select");

type.appendChild(new Listitem("字符串|String", "String"));

type.appendChild(new Listitem("整型|Int", "Int"));

type.appendChild(new Listitem("日期|Date", "Date"));

type.appendChild(new Listitem("長(zhǎng)整型|Long", "Long"));

type.appendChild(new Listitem("單精度|Single", "Single"));

type.appendChild(new Listitem("雙精度|Double", "Double"));

type.appendChild(new Listitem("貨幣|Currency", "Currency"));

type.appendChild(new Listitem("字節(jié)|Byte", "Byte"));

type.appendChild(new Listitem("布爾|Boolean", "Boolean"));

type.appendChild(new Listitem("時(shí)間|Time", "Time"));

type.appendChild(new Listitem("日期時(shí)間|Datetime", "Datetime"));

if (parameter.getType().contains("String")) {

type.setSelectedIndex(0);

} else if (parameter.getType().contains("Int")) {

type.setSelectedIndex(1);

} else if (parameter.getType().contains("Date")) {

type.setSelectedIndex(2);

} else if (parameter.getType().contains("Long")) {

type.setSelectedIndex(3);

} else if (parameter.getType().contains("Single")) {

type.setSelectedIndex(4);

} else if (parameter.getType().contains("Double")) {

type.setSelectedIndex(5);

} else if (parameter.getType().contains("Currency")) {

type.setSelectedIndex(6);

} else if (parameter.getType().contains("Byte")) {

type.setSelectedIndex(7);

} else if (parameter.getType().contains("Boolean")) {

type.setSelectedIndex(8);

} else if (parameter.getType().contains("Time")) {

type.setSelectedIndex(9);

} else if (parameter.getType().contains("Datetime")) {

type.setSelectedIndex(10);

} else {

type.setSelectedIndex(0);

}

// 每個(gè)Row添加一個(gè)defaultValue,賦值為當(dāng)前獲取參數(shù)的defaultValue

Textbox defaultValue = new Textbox();

defaultValue.setId("parameter_" + num);

defaultValue.setWidth("80px");

defaultValue.setValue(parameter.getDefaultValue());

defaultValue.setParent(row);

// 每個(gè)Row添加一個(gè)"刪除"按鈕,觸發(fā)刪除事件

Button delbtn = new Button();

delbtn.setId("delbtd_" + num);

delbtn.setLabel("刪除");

delbtn.addEventListener("onClick", new DelEventListener(num));

delbtn.setParent(row);

}

}

}

/**

* 添加參數(shù)

*/

public void addParameter() {

num = num + 1;

// 產(chǎn)生Row

Row row = new Row();

row.setId("row_" + num);

row.setParent(parameterRows);

Textbox name = new Textbox();

name.setId("name_" + num);

name.setWidth("80px");

name.setParent(row);

Listbox type = new Listbox();

type.setParent(row);

type.setId("type_" + num);

type.setMold("select");

type.appendChild(new Listitem("字符串|String", "String"));

type.appendChild(new Listitem("整型|Int", "Int"));

type.appendChild(new Listitem("日期|Date", "Date"));

type.appendChild(new Listitem("長(zhǎng)整型|Long", "Long"));

type.appendChild(new Listitem("單精度|Single", "Single"));

type.appendChild(new Listitem("雙精度|Double", "Double"));

type.appendChild(new Listitem("貨幣|Currency", "Currency"));

type.appendChild(new Listitem("字節(jié)|Byte", "Byte"));

type.appendChild(new Listitem("布爾|Boolean", "Boolean"));

type.appendChild(new Listitem("時(shí)間|Time", "Time"));

type.appendChild(new Listitem("日期時(shí)間|Datetime", "Datetime"));

type.setSelectedIndex(0);

Textbox defaultValue = new Textbox();

defaultValue.setId("parameter_" + num);

defaultValue.setWidth("80px");

defaultValue.setParent(row);

Button delbtn = new Button();

delbtn.setId("delbtd_" + num);

delbtn.setLabel("刪除");

delbtn.addEventListener("onClick", new DelEventListener(num));

delbtn.setParent(row);

}

/**

*

* @功能 監(jiān)聽事件 "刪除參數(shù)"

*

*/

public class DelEventListener implements EventListener {

int no;

public DelEventListener(int no) {

this.no = no;

}

@SuppressWarnings("unchecked")

public void onEvent(Event arg0) throws Exception {

// 移除才操作

win.getFellow("row_" + no).detach();

// 改變現(xiàn)有的,該行以后的所有行,上移一位

for (int i = no + 1; i <= num; i++) {

int j = i - 1;

win.getFellow("row_" + i).setId("row_" + j);

win.getFellow("name_" + i).setId("name_" + j);

win.getFellow("type_" + i).setId("type_" + j);

win.getFellow("parameter_" + i).setId("parameter_" + j);

Button bun = (Button) win.getFellow("delbtd_" + i);

Iterator ite = bun.getListenerIterator("onClick");

bun.removeEventListener("onClick", (EventListener) ite.next());

bun.setId("delbtd_" + j);

bun.addEventListener("onClick", new DelEventListener(j));

}

num--;

}

}

/**

* 保存選擇

*/

@SuppressWarnings("unchecked")

public void saveParameter() {

Map map = new HashMap();

// 定位到待保存的每一行

for (int i = 1; i <= num; i++) {

// 獲取頁(yè)面的輸入值

String name = ((Textbox) this.getFellow("name_" + i)).getValue()

.trim();

String type = (String) ((Listbox) this.getFellow("type_" + i))

.getSelectedItem().getValue();

String defaultValue = ((Textbox) this.getFellow("parameter_" + i))

.getValue();

// 當(dāng)name不為空且不重復(fù),則把頁(yè)面獲取的數(shù)據(jù)存入Parameter對(duì)象

if (!"".equals(name) && !map.containsKey(name)) {

Parameter tempparameter = new Parameter();

tempparameter.setName(name);

tempparameter.setType(type);

tempparameter.setDefaultValue(defaultValue);

// 再以name為鍵Parameter對(duì)象為值,存入一個(gè)Map對(duì)象

map.put(name, tempparameter);

} else if (map.containsKey(name)) {

Message.showInfo("第" + i + "行參數(shù)名已存在");

return;

} else {

Message.showInfo("第" + i + "行參數(shù)名不能為空");

return;

}

}

// 把已存的map作為參數(shù)列與report關(guān)聯(lián),并初始化頁(yè)面

num = 0;

inforreport.setParameters(map);

this.initiPage(inforreport.getParameters());

Message.showInfo("保存成功!");

}

}

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的java生成j动态页面_zk动态产生多个页面的例子代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。