友好声明:我是一个入门时间不长的菜鸟,所以别指望我能写出多么棒的文章。更不会把一些时髦的名词加进去。我只会用最普通的话,写出我在项目中对技术的想法和感悟,也同时希望高手牛人指点一下。

 

DWR?是AJAX里的一个框架,前几天项目重构的时候,使用到了它。之前我没接触过AJAX,只有一些基本的概念。所以.......充满好奇。

下面我把一个DWR小流程展示出来:

1、html页

首先,有一个按钮<button id="searchButton" name="searchButton" accessKey="s" style="float:right;margin-bottom:5px;">查询(<u>S</u>)</button>   其中ID:searchButton 

其次,脚本绑定部分:

Event.observe(window, 'load', function() {
      Event.observe('searchButton', 'click', searchAllRegulationByConditions);

  });   //这里给searchButton  这个按钮绑定了脚本事件,在click的时候调用searchAllRegulationByConditions。

最后是searchAllRegulationByConditions方法

function searchAllRegulationByConditions()
 {
        var formId="searchRglResultsForm";
       var parameterMap = getParameterMap(formId);   
       parameterMap["formId"]=[formId];
       parameterMap["invokeAction"]=["searchAllRegulationByConditions()"];
       var regulation=getRegulation("searchConditionForm");
       RegulationServiceSrv.searchUnionDynRecords(parameterMap,regulation,function(table)
                  {
                   $("regulationByCondition").update(table);
                   //getCheckedBoxs(formId);
                   //bindEvenetsToCheckBox(formId);
                  }
       );

}

注意加粗的部分,魔术开始了。

3、调用java类

类名为RegulationServiceSrv    ,   其中有个方法名为searchUnionDynRecords

至于searchUnionDynRecords里的内容,就是调用后面的DAO并使用里面的方法了。

最后在HTML页里的层里显示查询到的内容。

使用DWR的感觉:感觉真的很方便,并且很好的实现了代码的隐藏,利用dwr.xml暴露java类,后期改BUG也很舒服。我感觉,dwr就像是把业务逻辑都变成了平行线,焦点少了,可能出现的BUG也就少了,至于性能上的提升,目前感觉不明显。

评论
protti 2007-10-09
--Erroring: batchId[2] message[org.directwebremoting.extend.MarshallException: Error marshalling java.util.Date: For input string: "2007-09-01". See the logs for more details.]


今天遇到的一个问题,当我在时间字段里输入2007-09-01的时候。抱以上错误。

处理方法:(正在找解决办法.....)
protti 2007-09-14
希望看过菜鸟日记的人能指点一二,交流经验。
发表评论

您还没有登录,请登录后发表评论

protti
搜索本博客
存档
最新评论