2007年10月27日星期六

2007年10月26日 星期五

        对于javascript框架一直再用DWR,昨天听人说了个JQuery,不知道什么东西,在网上一查,也是个javascript框架,看论坛上的帖子好像功能还挺强大,落伍喽,就知道个DWR

        这不这两天就在折腾这东西,今天终于看到效果了

        下面是用DWR动态向table中添加行,并且设定行的css属性,比较爽,呵呵

function returnQueryRpt(list){
var cellfuncs = [  
            function(data){return data[1];},
            function(data){  
            var id = data[0];
            var rqname = data[2];
            return "<a href=\"javascript:printReport('" + rqname + "','" + id + "')\"><img src=\"<%=path%>/images/pic_edit.gif\" alt=\"填报或修改\" width=\"16\" height=\"16\" border=\"0\"></a>";  
            }
        ];
        DWRUtil.removeAllRows('addRowsBasic');   
        DWRUtil.addRows('addRowsBasic',list,cellfuncs,{  
        rowCreator:function(options) {  
            var row = document.createElement("tr");
            row.setAttribute("id",options.rowData.id);
            return row;  
        },  
        cellCreator:function(options) {  
            var td = document.createElement("td");
            td.style.color = "#003366";
            if(options.rowIndex%2==0){
             td.style.backgroundColor = "#F5f5f5";
            }else{
             td.style.backgroundColor = "#E6EEF7";
            }
            return td;  
        }         
        });
}



****************************************************************************************************************


2008-01-15补充
今天更新成了dwr2.0.2
有以下改动
1、首先启动报错
- Marking servlet dwr-invoker as unavailable
- Error loading WebappClassLoader
delegate: false
repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@9fdee
uk.ltd.getahead.dwr.DWRServlet
java.lang.ClassNotFoundException: uk.ltd.getahead.dwr.DWRServlet

dwr官方网站有如下解释
The DWR package has changed from uk.ltd.getahead to org.directwebremoting. There are deprecated stubs in place for backwards compatibility, however more future proof code will use the new package names. The change that will affect most people is the altered servlet name. The preferred name is now: org.directwebremoting.servlet.DwrServlet
改成<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>就OK了

2、上面的例子如果直接升级到2.0会直接出来html代码
要加上下面这句
dwr.util._escapeHtml = false;
如果为true,就直接
出来html代码

3、
DWRUtil 改成了 dwr.util


没有评论:

发表评论