« Echo2 Web Framework | Main | Bugtracker - Complete Bug & Issue Management System »

Direct Web Remoting - DWR





Direct Web Remoting(DWR) allows Javascript in a browser to interact with Java on a server and helps you manipulate web pages with the results.

DWR is Easy Ajax for Java

DWR is a Java open source library which allows you to write Ajax web sites.

It allows code in a browser to use Java functions running on a web server just as if it was in the browser.

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 works by dynamically generating Javascript based on Java classes. The code does some Ajax magic to make it feel like the execution is happening on the browser, but in reality the server is executing the code and DWR is marshalling the data back and forwards.

This method of remoting functions from Java to JavaScript gives DWR users a feel much like conventional RPC mechanisms like RMI or SOAP, with the benefit that it runs over the web without requiring web-browser plug-ins.

Java is fundamentally synchronous where Ajax is asynchronous. So when you call a remote method, you provide DWR with a callback function to be called when the data has been returned from the network.

The diagram shows how DWR can alter the contents of a selection list as a result of some Javascript event like onclick.



DWR dynamically generates an AjaxService class in Javascript to match some server-side code. This is called by the eventHandler. DWR then handles all the remoting details, including converting all the parameters and return values between Javascript and Java. It then executes the supplied callback function (populateList) in the example below which uses a DWR utility function to alter the web page.

DWR helps you in producing highly interactive web-sites by providing some Javascript libraries to help with DHTML and by giving you a set of examples to copy from.

Direct Web Remoting(DWR) Project Home Page
http://getahead.org/dwr

Download Direct Web Remoting(DWR)
http://getahead.org/dwr/download

Direct Web Remoting(DWR) Documentation
http://getahead.org/dwr/documentation

TrackBack

TrackBack URL for this entry:
http://freejdk.org/mt-tb.cgi/74