/**
**QQ:252574345
**MSN:lele_love_lomboz@hotmail.com
*/
本文并未提供完整源代码,请见谅
1、配置dwr.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
<allow>
<create creator="new" javascript="status">
<param name="class" value="StatusBusiness"/> //为DWR实现类
</create>
<convert converter="bean" match=User"> //PO类
</convert>
</allow>
</dwr>
2、DWR类:StatusBusiness类
/**
* 返回select框数据集合
* @param id
* @param action
* @return
*/
public List getSelectList(String id,String action){
//为文章结构清晰,以下代码省略
//此list为PO类user的集合
return list;
}
3、PO类
public class User extends BasePO
{
private String id;
private String name;
//getter and setter
}
4、AJAX:dwr处理
...页面中
<script>
function initUserGroup(id,selectobj){
var edatasetid="12wsw83ks";
var eaction="action=getUserlist&id="+id;
status.getSelectList(edatasetid,eaction,getListEditx);
function getListEditx(data)
{
if(null!=data&&data.size>0)
{
//清除原select,否则重复对select赋值
optionsClear(selectobj);
for(var i=0;i<data.length;i++)
{
//将回调函数返回的list对象边历,循环取出PO类对象user的id和name属性,放在页面上对应select里
selectobj.options[selectobj.options.length] = new Option(data[i].id,data[i].name);
}
}
}
}
<script>