DWR Advanced topic DWR with Spring integration (not using SPRINGMVC, but using annotations for instances)
----------
Xml
<?xml version= "1.0" encoding= "iso-8859-1"?> <! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.3//en" "http://java.sun.com/dtd/web-app_2 _3.dtd "> <web-app id=" Dwr_dev "> <listener> <listener-class>org.springframework.web.context.c ontextloaderlistener</listener-class> </listener> <context-param> <param-name>contextco Nfiglocation</param-name> <param-value> Classpath:dwr3SampleAppSpring3AnnotNonSpringMVC.xml & lt;/param-value> </context-param> <servlet> <servlet-name>dwr</servlet-name> & Lt;servlet-class>org.directwebremoting.spring.dwrspringservlet</servlet-class> <init-param> < ;p aram-name>debug</param-name> <param-value>true</param-value> </init-param> <
;/servlet> <servlet-mapping> <servlet-name>dwr</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> </web-app>
Spring's bean configuration file
<?xml version= "1.0" encoding= "UTF-8"?> <beans
xmlns= "Http://www.springframework.org/schema/beans"
xmlns:context= "Http://www.springframework.org/schema/context"
xmlns:dwr= "http// Www.directwebremoting.org/schema/spring-dwr "
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "
xsi : schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.0.xsd
Http://www.springframework.org/schema/context http://www.springframework.org/schema/ Context/spring-context-3.0.xsd
Http://www.directwebremoting.org/schema/spring-dwr/http Www.directwebremoting.org/schema/spring-dwr-3.0.xsd ">
<dwr:configuration/>
<dwr: Annotation-scan base-package= "Org.uk.ltd.dwr.dev" scandatatransferobject= "true" scanremoteproxy= "true"/>
</beans>
Java files
Package Org.uk.ltd.dwr.dev.model;
Import Org.directwebremoting.annotations.DataTransferObject;
@DataTransferObject public
class Address {
private String Street;
Private String Street2;
Private String city;
Private String State;
Public String Getstreet () {
return street;
}
public void Setstreet (String street) {
this.street = Street;
}
Public String GetStreet2 () {
return street2;
}
public void SetStreet2 (String street2) {
This.street2 = Street2;
}
Public String getcity () {
return city;
}
public void Setcity (String city) {
this.city = city;
}
Public String getState () {
return state;
}
public void SetState (String state) {
this.state = state;
}
}
Package org.uk.ltd.dwr.dev.service;
Import Org.directwebremoting.annotations.RemoteMethod;
Import Org.directwebremoting.annotations.RemoteProxy;
Import org.uk.ltd.dwr.dev.model.Address;
@RemoteProxy (name= "Dwrservice") public
class Dwrservice {public
Dwrservice () {}
@RemoteMethod
Public Address getaddress () throws Exception {
address address = new Address ();
Address.setstreet ("2245 NW Overlook Drive");
Address.setcity ("Portland");
Address.setstate ("Oregon");
return address;
}
@RemoteMethod public
void Printaddress () {
System.out.println ("Printing");
}
}
Index.html