DWR util.js 學習筆記 整理
2024-09-01 08:29:46
供稿:網友
util.js包含一些有用的函數function,用于在客戶端頁面調用,它可以和dwr分開,獨立營用于你的系統中。
主要功能如下:
1、$() 獲得頁面參數值
2、addOptions and removeAllOptions 初始化下拉框
3、addRows and removeAllRows 填充表格
4、getText 取得text屬性值
5、getValue 取得form表單值
6、getValues 取得form多個值
7、onReturn
8、selectRange
9、setValue
10、setValues
11、toDescriptiveString
12、useLoadingMessage
13、Submission box
***************************************************************************************
//////////////////////////////////////////////////////////////////////////////////////
****************************************************************************************
1、$()函數
IE5.0 不支持
$ = document.getElementById
取得form表單值
var name = $("name");
***************************************************************************************
//////////////////////////////////////////////////////////////////////////////////////
****************************************************************************************
2、用于填充 select 下拉框 option
a、如果你想在更新select 時,想保存原來的數據,即在原來的select中添加新的option:
var sel = DWRUtil.getValue(id);
DWRUtil.removeAllOptions(id);
DWRUtil.addOptions(id,...);
DWRUtil.setValue(id,sel);
demo:比如你想添加一個option:“--請選擇--”
DWRUtil.addOptions(id,["--請選擇--"]);
DWRUtil.addOptions()有5中方式:
@ Simple Array Example: 簡單數組
例如:
Array array = new Array[ 'Africa', 'America', 'Asia', 'Australasia', 'Europe' ];
DWRUtil.addOptions("demo1",array);
@ Simple Object Array Example 簡單數組,元素為beans
這種情況下,你需要指定要顯示 beans 的 property 以及 對應的 bean 值
例如:
public class Person {
private String name;
private Integer id;
pirvate String address;