- 浏览: 551696 次
- 性别:
- 来自: 青岛
文章分类
最新评论
-
myworkfirst:
这个mShowing是哪里的定义的? 有没有完整的例子
通过反射重新设置设置Dialog -
mchaoliu:
楼主,这个方法是在哪调用呢?
修改快速滑动滑块的图片为新浪微博滑块样式 -
fxiaozj:
楼主,这个方法是在哪调用呢?
修改快速滑动滑块的图片为新浪微博滑块样式 -
yun2223:
感谢一下,把gen 添加到source 以及检查一下 其他路 ...
gen already exists but is not a source folder -
flyingsir_zw:
解决方法: 1. 右键点击工程,选择 "Proper ...
gen already exists but is not a source folder
dwr util使用
2010-08-07 23:11
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 = dwr.util.getValue(id); dwr.util.removeAllOptions(id); dwr.util.addOptions(id,...); dwr.util.setValue(id,sel); demo:比如你想添加一个option:“--请选择--” dwr.util.addOptions(id,["--请选择--"]); dwr.util.addOptions()有5中方式: @ Simple Array Example: 简单数组 例如: Array array = new Array[ 'Africa', 'America', 'Asia', 'Australasia', 'Europe' ]; dwr.util.addOptions("demo1",array); @ Simple Object Array Example 简单数组,元素为beans 这种情况下,你需要指定要显示 beans 的 property 以及 对应的 bean 值 例如: public class Person { private String name; private Integer id; pirvate String address; public void set(){……} public String get(){……} } dwr.util.addOptions("demo2",array,'id','name'); 其中id指向及bean的id属性,在optiong中对应value,name指向bean的name属性,对应下拉框中显示的哪个值. @ Advanced Object Array Example 基本同上 dwr.util.addOptions( "demo3", [{ name:'Africa', id:'AF' }, { name:'America', id:'AM' }, { name:'Asia', id:'AS' }, { name:'Australasia', id:'AU' }, { name:'Europe', id:'EU' } ],'id','name'); @ Map Example 用制定的map来填充 options: 如果 server 返回 Map,呢么这样处理即可: dwr.util.addOptions( "demo3",map); 其中 value 对应 map keys,text 对应 map values; @ <ul> and <ol> list editing dwr.util.addOptions() 函数不但可以填出select,开可以填出<ul>和<ol>这样的heml元素 *************************************************************************************** ////////////////////////////////////////////////////////////////////////////////////// **************************************************************************************** 3、addRows and removeAllRows 填充表格 DWR 提供2个函数来操作 table; ---------------------------- dwr.util.addRows(); 添加行 ---------------------------- dwr.util.removeAllRows(id); 删除指定id的table ---------------------------- 下面着重看一下 addRows() 函数: dwr.util.addRows(id, array, cellfuncs, [options]); 其中id 对应 table 的 id(更适合tbodye,推荐使用 tbodye) array 是server端服务器的返回值,比如list,map等等 cellfuncs 及用返回值来天春表格 [options] 用来设置表格样式,它有2个内部函数来设置单元格样式(rowCreator、cellCreator)。 比如: server端返回list,而list中存放的是下面这个 bean: public class Person { private String name; private Integer id; pirvate String address; public void set(){……} public String get(){……} } 下面用 dwr.util.addRows(); /**************************************************************************************/ /**************************************************************************************/ function userList(data){ //var delButton = "<input type='button'/>"; //var editButton = "<input type='button'/>"; var cellfuncs = [ function(data){return data.id;}, function(data){return data.userName;}, function(data){return data.userTrueName;}, function(data){return data.birthday;}, function(data){ var idd = data.id; var delButton = document.createElement("<INPUT TYPE='button' onclick='delPerson("+ idd +")'>"); delButton.setAttribute("id","delete"); delButton.setAttribute("value","delete"); return delButton; }, function(data){ var idd = data.id; var editButton = document.createElement("<INPUT TYPE='button' onclick='editPerson("+ idd +")'>"); editButton.setAttribute("name","edit"); editButton.setAttribute("value","edit"); return editButton; } ]; dwr.util.removeAllRows('tabId'); dwr.util.addRows('tabId', data,cellfuncs,{ rowCreator:function(options) { var row = document.createElement("tr"); var index = options.rowIndex * 50; row.setAttribute("id",options.rowData.id); row.style.collapse = "separate"; row.style.color = "rgb(" + index + ",0,0)"; return row; }, cellCreator:function(options) { var td = document.createElement("td"); var index = 255 - (options.rowIndex * 50); //td.style.backgroundColor = "rgb(" + index + ",255,255)"; td.style.backgroundColor = "menu"; td.style.fontWeight = "bold"; td.style.align = "center"; return td; } }); document.getElementById("bt").style.display = "none"; } 待续………………………………………… /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ 4、getText 取得text属性值 dwr.util.getText(id): 用来获得 option 中的文本 比如: <select id="select"> <option value="1"> 苹果 </option> <option value="2" select> 香蕉 </option> <option value="3"> 鸭梨 </option> </select> 调用 dwr.util.getText("select"); 将返回 "香蕉" 字段; dwr.util.getText(id);仅仅是用来获得 select 文本值,其他不适用。 /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ 5、dwr.util.getValue(id): 用来获得 form 表单值 有如下几种情况: Text area (id="textarea"): dwr.util.getValue("textarea")将返回 Text area的值; Selection list (id="select"): dwr.util.getValue("select") 将返回 Selection list 的值; Text input (id="text"): dwr.util.getValue("text") 将返回 Text input 的值; Password input (id="password"): dwr.util.getValue("text") 将返回 Password input 的值; Form button (id="formbutton"): dwr.util.getValue("formbutton") 将返回 Form button 的值; Fancy button (id="button"): dwr.util.getValue("formbutton") 将返回 Fancy button 的值; /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ 6、getValues 取得form多个值 批量获得页面表单的值,组合成数组的形式,返回 name/value; 例如: form(): <input type="textarea" id="textarea" value="1111"/> <input type="text" id="text" value="2222"/> <input type="password" id= "password" value="3333"/> <select id="select"> <option value="1"> 苹果 </option> <option value="4444" select> 香蕉 </option> <option value="3"> 鸭梨 </option> </select> <input type="button" id="button" value="5555"/> 那么: dwr.util.getValues({textarea:null,select:null,text:null,password:null,button:null}) 将返回 ^^^^^^^^^^^^^^^^{textarea:1111,select:4444,text:2222,password:3333,button:5555} /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ 7、dwr.util.onReturn 防止当在文本框中输入后,直接按回车就提交表单。 <input type="text" onkeypress="dwr.util.onReturn(event, submitFunction)"/> <input type="button" onclick="submitFunction()"/> /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ 8、dwr.util.selectRange(ele, start, end); 在一个input box里选一个范围 dwr.util.selectRange("sel-test", $("start").value, $("end").value); 比如:<input type="text" id="sel-test" value="012345678901234567890"> dwr.util.selectRange("sel-test", 2, 15); 结果 文本框中的值"2345678901234"将被选中' /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ 9、dwr.util.setValue(id,value); 为指定的id元素,设置一个新值; /**************************************************************************************/ 10、dwr.util.setValues({ name: "fzfx88", password: "1234567890" } ); 同上,批量更新表单值. /**************************************************************************************/ 11、dwr.util.toDescriptiveString() 带debug信息的toString,第一个为将要debug的对象,第二个参数为处理等级。等级如下: 0: Single line of debug 单行调试 1: Multi-line debug that does not dig into child objects 不分析子元素的多行调试 2: Multi-line debug that digs into the 2nd layer of child objects 最多分析到第二层子元素的多行调试 <input type="text" id="text"> dwr.util。toDescriptiveString("text",0); /**************************************************************************************/ 12、dwr.util.useLoadingMessage(); 当发出ajax请求后,页面显示的提示等待信息; function searchUser(){ var loadinfo = "loading....." try{ regUser.queryAllUser(userList); dwr.util.useLoadingMessage(loadinfo); }catch(e){ } } /**************************************************************************************/ |
http://hi.baidu.com/wangchao_cn/blog/item/979e953855c793cfd4622532.html
- dwr_util_api.rar (19.1 KB)
- 下载次数: 28
发表评论
-
unicode 转gb2312
2012-03-27 15:00 2378做项目的时候经常遇到unicode码的问题,比如json数据格 ... -
javascript 项目笔记
2011-12-23 11:11 1245判断判断某个变量/属性是否为undefined // ... -
找不到方法的原因
2011-06-22 19:05 954看下面一段代码: <html> <hea ... -
confirm 提示菜单
2011-06-03 17:07 1039几种关于确认取消提示的js效果: 1. var con = ... -
frameset
2011-05-28 14:46 1069frameset和body是平行的标签 frameset不要 ... -
控制textarea 只能输入200个以内的字符
2011-05-16 16:58 1983控制textarea 只能输入200个以内的字符。 < ... -
火狐自带的表单验证。。
2011-03-31 14:37 1033required样式: 前几天做项目的时候,一张页面加了表单 ... -
javascriot记事本
2011-03-28 16:44 1350<script language="javas ... -
分页核心代码
2011-03-21 22:19 578/** * 获取当前页的数据源 * @param st ...
相关推荐
dwr包.rar dwr.jar engine.js util.js dwr-noncla.jar readme.txt JAR File: dwr.jar (1.08Mb) To DWR enable your web-app WAR File: dwr.war (4.62Mb) Demos/Examples of what DWR can do Sources: dwr-...
dwr javascript util.js engind.js 工具库 原js文件在dwr.jar中,不想找的同学就下载吧。
DWR(包括engine.js+util.js).rar
dwr教程+dwr.jar+util.js+engine.js
开发Dwr所需的jar包,js文件:dwr.jar engine.js util.js
技术分享:DWR 处理各种form表单Selectoption,table等,List,Bean
util.js包含一些有用的函数function,用于在客户端页面调用,它可以和dwr分开,独立营用于你的系统中。 主要功能如下: 1、$() 获得页面参数值 2、addOptions and removeAllOptions 初始化下拉框 3、addRows and...
dwr-1.1.1-util.js
dwr需要的js(searchaAuthor+engine.js+util.js).rar
自己整理的dwr中util.js的常用方法
这是dwr需要的engine.js和util.js,Engine.js与util.js不同之处在于,util.js是静态js文件,可以直接从jar文件中拿出来,页面可以直接引用;而engine.js则有部分动态内容,这决定了它必须经过servelt资源请求,在...
dwr 例子 jar包 engine.jsutil.js 学习笔记 绝对超值。
dwr-2.0-util.js
dwr城市选择的联动,util.js方法的使用,动态table
springboot整合dwr实现js调用java方法,页面支持freemarker和jsp
DWR是是关于开发web2.0...第7章.util.js的功能,含13小节;第8章.DWR进阶,含5小节;第9章.范例精讲——购物车,含8小节;第10章.附录,含常见问题(4节)和JavaScript高级应用(5节)。希望对于像我一样的初学者有所帮助^_^
默认的时候DWR将java void值转换成javascript的null值就是这样设置<convert converter="null" match="void"/>. 有时java.lang.Void也需要进行这样的转换,所以设置也是相似的<convert converter="null" match="java....