Dwr
-
Upload
andre-mayer -
Category
Technology
-
view
1.179 -
download
0
description
Transcript of Dwr
@Andre_Mayer
wtf dwr?
• DWR¹ is a Java library that enables Java on the server and JavaScript in a browser to interact and call each other as simply as possible.
• DWR is Easy Ajax² for Java
¹ Direct Web Remoting²Asynchronous Javascript and XML
Joe Walker
DWR consists of two main parts:– A Java Servlet running on the server that
processes requests and sends responses back to the browser.
– JavaScript running in the browser that sends requests and can dynamically update the webpage.
• DWR will generate the JavaScript to allow web browsers to call Java code. It can marshal virtually any data (using JSON) including collections, POJOs, XML and binary data like images and PDF files.
why use dwr?
DWR will give you productivity by enabling you call your java classes/methods with very few lines of javascript code
script browser sideAvoid complex XMLHttpRequest code, DOM manipulation, use DWR instead ;)
web.xml
dwr.xml
This definitions will generate javascript file in runtime named Chat.js
5
Chat.js
engine.js
it works!!
Advantages Disadvantages
Easy integration between Java and JavaScript
Only works in Java platform.
Integrates with Spring Beans; Marshalling: JSON may be unsafe unless you are using unpredictable URLs.
Real possibility to keep your MVC standard
Going through not standard way in “transfer technologies” using AJAX (old-fashion) instead web sockets (socket.io)
Integrates with leading Java Frameworks (Spring, JSF, Hibernate)
Debugging in console;
Cross-browser