论坛首页 Java企业应用论坛

DWR使用过程中的几个问题

浏览 4829 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-01-06  

1dwrspring的集成。

<o:p>
dwr.xml<o:p></o:p>代码
  1. <!---->xml version="1.0" encoding="UTF-8"?>    
  2.   
  3.         "http://www.getahead.ltd.uk/dwr/dwr10.dtd">    
  4. <dwr>    
  5.     <allow>   
  6.         <create creator="spring" javascript="UserDAO">  
  7.             <param name="beanName" value="userDao"/>  
  8.             <include method="addUser"/>   
  9.             <include method="removeUser"/>  
  10.             <include method="findUserByName"/>  
  11.         create>  
  12.          <convert converter="bean" match="martin.dwr.demo.model.User">  
  13.             <param name="include" value="id,name,password,age"/>  
  14.         convert>    
  15.     allow>  
  16. dwr>  
  17.   

 

<o:p>
web.xml<o:p></o:p>代码
  1. <!---->xml version="1.0" encoding="UTF-8"?>  
  2.         "http://java.sun.com/dtd/web-app_2_3.dtd">  
  3. <web-app>  
  4.     <context-param>  
  5.         <param-name>contextConfigLocationparam-name>  
  6.         <param-value>/WEB-INF/classes/applicationContext.xmlparam-value>  
  7.     context-param>  
  8.     <listener>  
  9.         <listener-class>  
  10.             org.springframework.web.context.ContextLoaderListener   
  11.         listener-class>  
  12.     listener>  
  13.     <servlet>  
  14.         <servlet-name>dwr-invokerservlet-name>  
  15.         <servlet-class>uk.ltd.getahead.dwr.DWRServletservlet-class>  
  16.         <init-param>  
  17.             <param-name>debugparam-name>  
  18.             <param-value>trueparam-value>  
  19.         init-param>  
  20.         <init-param>  
  21.             <param-name>config-adminparam-name>  
  22.             <param-value>WEB-INF/classes/dwr.xmlparam-value>  
  23.         init-param>  
  24.     servlet>  
  25.     <servlet-mapping>  
  26.        <servlet-name>dwr-invokerservlet-name>  
  27.         <url-pattern>/dwr/*url-pattern>  
  28.     servlet-mapping>  
  29. web-app>  

 

applicationContext.xml<o:p></o:p>代码

  1. <bean id="userDao" class="martin.dwr.demo.dao.hibernate.HibernateUserDAO">  
  2.         <property name="sessionFactory" ref="sessionFactory"/>  
  3.     </bean>  

 

2dwrstruts的集成问题。<o:p></o:p>

   Dwr.xml代码

<o:p>
  1. <dwr>  
  2.     <allow>  
  3.         <convert converter="bean" match="dwr.demo.Goods"/>  
  4.         <create creator="new" javascript="DemoAction" class="dwr.demo.DemoAction">  
  5.             <include method="query4dwr"/>  
  6.             <include method="copy4dwr"/>  
  7.             <include method="paste4dwr"/>  
  8.         create>  
  9.         <create creator="new" javascript="DemoFacade" class="dwr.demo.DemoFacade">  
  10.             <include method="queryList"/>  
  11.             <include method="restore"/>  
  12.             <include method="del"/>  
  13.         create>  
  14.       allow>  
  15. dwr>  
</o:p></o:p></o:p>  

      这里建议直接使用DAO的方法,直接在View层中调用DAO,破坏了程序的层次;利用action进行统一的处理,会不会有生产js的效率问题,是否可以新建一个dwr 包让View直接与其通信?

   发表时间:2007-01-06  
DWR也属于VIEW层,个人在应用中使用DWR Annotation,和AjaxService来进行通信。

@RemoteProxy(creator = SpringCreator.class, name = "Service", creatorParams = @Param(name = "beanName", value = "AjaxService"))
public class AjaxDWRService extends AjaxService {
		
	public AjaxDWRService() {
	}

	@RemoteMethod
	public List getRoles(String depname) {
	}

	@RemoteMethod
	public List getModNmames() {
	}

	@RemoteMethod
	public List getModule(int moduleId) {
	}
}

0 请登录后投票
   发表时间:2007-01-06  
小弟对DWR也是刚刚接触,还请boin大哥多多指点!
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics