Home » News » Javascript in Java: Getahead R ...

News by JavaScriptSearch


Javascript in Java: Getahead Releases DWR 2.0 Milestone 2

 

JavaScriptSearch
Monday, May 8, 2006; 03:20 AM

The small IT consultancy Getahead released DWR 2.0 milestone 2 - an open source Java library which allows developers 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 2.0 has a set of new experimental APIs that allows users to use Java and the familiarity of the language and IDE to write Javascript.

The creators of DWR have put online a manual, as well as pages with tutorials and version history.  Here is a detailed description of DWR from the official 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."

 


http://getahead.ltd.uk/dwr/

Advertisement

Partners

Related Resources

Other Resources

arrow