AJAX With DWR(Direct Web Remoting) GouthamV Software Engineer InfoGroup
    AJAX (Asynchronous JavaScript And Xml) <ul><li>Not one technology, several technologies </li></ul><ul><li>XHTML and CS...
AJAX architecture with toolkits
  Examples of AJAX GMail Google Maps Google Suggest Flickr
AJAX implementation toolkits  <ul><li>DWR </li></ul><ul><li>DOJO </li></ul><ul><li>Scriptaculous </li></ul><ul><li>Prototy...
Why DWR? Most commonly used toolkit in java environment according to Google and Burton Group (research and advisory servic...
Why JSON? Lightweight data-interchange format  Easy for humans to read and write Easy for machines to parse and generate v...
DWR architecture with example
OE example with DWR   (Existing problem) <ul><li>Steps Involved: </li></ul><ul><li>Selcet source, submit form </li></ul><u...
  DWR  configuration steps 1.Copy dwr.jar to lib folder 2. Add DWR servlet details in web.xml 3. Create dwr.xml in web-inf...
Sample DWR Servlet <ul><li><servlet> </li></ul><ul><li><servlet-name>dwr</servlet-name> </li></ul><ul><li><servlet-class>u...
DWR and Spring  Tighter integration with Spring   No more dwr.xml but ordinary Spring XML  DWR controller (instead of DWR ...
DWR Advanced features Batching: beginBatch() make some dwr request endBatch() Accessing servlet parameters: WebContext ctx...
DWR  Scriptaculous  Dojo  Prototype  1.  Java-exclusive  -- seems to be Java code that generates JavaScript. This limits i...
Conclusion  DWR improves the user experience.  Integrates nicely with Spring.  Testing DWR functionality is easy by settin...
DWR Resources  Ajax Hacks(ch 5), Bruce W.Perry, O’Reilly.  JDJ,  OCT-06  Issue. http://bram.jteam.nl/files/dwr_and_spring....
Upcoming SlideShare
Loading in …5
×

Ajax with DWR

2,934 views
2,809 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,934
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Ajax with DWR

  1. 1. AJAX With DWR(Direct Web Remoting) GouthamV Software Engineer InfoGroup
  2. 2. AJAX (Asynchronous JavaScript And Xml) <ul><li>Not one technology, several technologies </li></ul><ul><li>XHTML and CSS </li></ul><ul><li>Document Object Model (DOM) </li></ul><ul><li>XML (and XSLT) </li></ul><ul><li>XMLHttpRequest (XHR) </li></ul><ul><li>JavaScript </li></ul>
  3. 3. AJAX architecture with toolkits
  4. 4. Examples of AJAX GMail Google Maps Google Suggest Flickr
  5. 5. AJAX implementation toolkits <ul><li>DWR </li></ul><ul><li>DOJO </li></ul><ul><li>Scriptaculous </li></ul><ul><li>Prototype </li></ul><ul><li>JSON – RPC </li></ul><ul><li>and many more… </li></ul>
  6. 6. Why DWR? Most commonly used toolkit in java environment according to Google and Burton Group (research and advisory services in IT architecture and infrastructure decisions) Java to JavaScript marshalling and vice versa Integrates best with Spring! Uses JavaScript objects also called JSON(Java Script Object Notation)
  7. 7. Why JSON? Lightweight data-interchange format Easy for humans to read and write Easy for machines to parse and generate var myJSONObject = { &quot;web&quot;:[ { &quot;name&quot;: &quot;html&quot;, &quot;years&quot;: &quot;5&quot; }, { &quot;name&quot;: &quot;css&quot;, &quot;years&quot;: &quot;3&quot; }] } JSON Vs XML: Light and Faster than XML. JSON types: String, number, array, boolean but XML all strings. Reading values from JSON object is same as java object, but reading XML needs tedious DOM APIs.
  8. 8. DWR architecture with example
  9. 9. OE example with DWR (Existing problem) <ul><li>Steps Involved: </li></ul><ul><li>Selcet source, submit form </li></ul><ul><li>Sending all details including ordertype, qty, unitprice, amounts, shipping details etc.. </li></ul><ul><li>At Server side, controller process all these details but sends only items for that source. </li></ul><ul><li>Result: Extra overhead on conroller, delay, loading page again from header to footer with same information. </li></ul>
  10. 10. DWR configuration steps 1.Copy dwr.jar to lib folder 2. Add DWR servlet details in web.xml 3. Create dwr.xml in web-inf folder to configure DWR 4. Write Java classes that dwr will use for Ajax functionality 5. Call methods of those classes from Java script.
  11. 11. Sample DWR Servlet <ul><li><servlet> </li></ul><ul><li><servlet-name>dwr</servlet-name> </li></ul><ul><li><servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class> </li></ul><ul><li><init-param> </li></ul><ul><li><param-name>debug</param-name> </li></ul><ul><li><param-value>true</param-value> </li></ul><ul><li></init-param> </li></ul><ul><li></servlet> </li></ul><ul><li><servlet-mapping> </li></ul><ul><li><servlet-name>dwr</servlet-name> </li></ul><ul><li><url-pattern>/dwr/*</url-pattern> </li></ul><ul><li></servlet-mapping> </li></ul>
  12. 12. DWR and Spring Tighter integration with Spring No more dwr.xml but ordinary Spring XML DWR controller (instead of DWR Servlet) <ul><li>Use the ServletWrappingController to wrap the DWRServlet </li></ul><ul><li><bean id=&quot;dwrController&quot; class=&quot;org.sfw.web.servlet.mvc.ServletWrappingController&quot;> </li></ul><ul><ul><li><property name=&quot;servletClass“ value=&quot;uk.ltd.getahead.dwr.DWRServlet&quot;/> </li></ul></ul><ul><ul><li><property name=&quot;initParameters&quot;> </li></ul></ul><ul><li><props> </li></ul><ul><li><prop key=&quot;debug&quot;>true</prop> </li></ul><ul><li></props> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul>
  13. 13. DWR Advanced features Batching: beginBatch() make some dwr request endBatch() Accessing servlet parameters: WebContext ctx = WebContextFactory.get(); ctx.getHttpServletRequest(); ctx.getHttpServletResponse(); ctx.getServletContext(); GMail style loading messages DWRUtil.useLoadingMessage(‘Waiting…’);
  14. 14. DWR Scriptaculous Dojo Prototype 1. Java-exclusive -- seems to be Java code that generates JavaScript. This limits its utility in non-Java environments. 1. No IE5.x support 1.Documentation is lacking. 2. Client has to include large size javascript files. 1.IE support is limited to IE6. 2. No documenta- tion other than Readme!!. 3. Has no visual effects library. 1. Good integration with Java. 2. Extensive documentation . 3. Integration with projects (Spring, XOM, Dom4J) 1. Lots of neat visual effects. 2. Simple and easy to understand object-oriented design. 1.Browser compatibility targets are: IE,FireFox,Safari. 2.Core parts are unit tested, has good visual effects 1.It can be used in any environment. 2. Foundation for other toolkits. 3. Provides fairly low-level access to XMLHttpRequest. C O N S P R O S
  15. 15. Conclusion DWR improves the user experience. Integrates nicely with Spring. Testing DWR functionality is easy by setting debug to true. Hides XMLHttpRequest javascript implementation. Can be used along with other UI toolkits(eg. Scriptaculous, Dojo…) etc…
  16. 16. DWR Resources Ajax Hacks(ch 5), Bruce W.Perry, O’Reilly. JDJ, OCT-06 Issue. http://bram.jteam.nl/files/dwr_and_spring.pdf . www.ajaxload.info (loading panel gifs)

×