zhulin902 发表于 2013-1-23 01:33:31

Appfuse dwr实现

修改web.xml中的参数,把*,/dwr/*去掉,可以到StaticFilter查看实现机制

<filter>      <filter-name>staticFilter</filter-name>      <filter-class>com.byd.logfee.webapp.filter.StaticFilter</filter-class>      <init-param>            <param-name>includes</param-name>            <param-value>/scripts/dojo/*,/dwr/*</param-value>      </init-param></filter>


到dwr.xml中配置相关参数 参考:http://directwebremoting.org/dwr/server/dwrxml/index.html

其中getList,getHelloString为自己定义的函数

<dwr>    <allow>      <create creator="spring" javascript="UserManager">            <param name="class" value="com.byd.logfee.service.UserManager"/>            <param name="beanName" value="userManager"/>            <include method="getUsers"/>            <include method="getList"/>            <include method="getHelloString"/>      </create>   </allow></dwr>

可以通过下面地址对所写的函数进行测试,http://localhost:8009/logfee/dwr/index.html

参考:Ajax开发精要——概念、案例与框架 http://book.csdn.net/bookfiles/159/1001596838.shtml


加入相关脚本连接,很重要,在测试页面有的,都需要加入

<mce:script type='text/javascript' src="/logfee/dwr/interface/UserManager.js" mce_src="logfee/dwr/interface/UserManager.js"></mce:script><mce:script type='text/javascript' src="/logfee/dwr/engine.js" mce_src="logfee/dwr/engine.js"></mce:script><mce:script type='text/javascript' src="/logfee/dwr/util.js" mce_src="logfee/dwr/util.js"></mce:script>      调用服务器端函数 参考:DWR中文官方文档 <div class="right">   <s:select label="%{getText('houseBasicPara.houseName')}" id = "Demo" cssClass="text medium"    name="houseBasicPara.houseName"list="houseNameList"></s:select></div>function callHouseName()    {       dwr.util.removeAllOptions("Demo");      UserManager.getList(function(data){dwr.util.addOptions("Demo", data);});    }

相关参考网站: http://directwebremoting.org/dwr/server/dwrxml/index.html

http://www.blogjava.net/heyday/archive/2008/05/13/200254.html
http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseAjaxWithDWR

http://appfuse.org/display/APF/Ajax
页: [1]
查看完整版本: Appfuse dwr实现