Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Direct Web Remoting (DWR) work?

How exactly or what exactly does Direct Web Remoting (DWR) do? While I have already gone through the official site http://directwebremoting.org/ I wanted to understand in simple language..

Specifically I have following questions; 1. While engine.js is standard Javascript library, how exactly does it help in including that in our app ? 2. What is so special about DWR that cannot be done by normal Javascript / AJAx combination?

Thank you.

like image 304
copenndthagen Avatar asked May 24 '11 06:05

copenndthagen


People also ask

What is DWR servlet?

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.

What is DWR in spring?

Web Application development with DWR(direct web remoting) and Spring Boot. DWR is a Java library which allows JavaScript functions to call Java methods and Java methods to call JavaScript functions(reverse ajax).

How do I debug DWR?

If you want to debug/test the DWR calls, the DWR Servlet needs to be in debug mode in the web. xml file. To enable debug, set the parameter for debug to true. Note that this is probably not desirable in production because it shows all available methods of the object to the client.


1 Answers

OK, I've only had a brief look at DWR and I was wondering the same thing. As far as I can gather DWR builds and includes on your page some javascript that mirrors your server-side java. It will generate client-side proxies that you can call in your javascript. So instead of using jquerys $.ajax(...) command and specifying the url, data type, data, etc, you can just use RemoveObj.doSomeStuff(...) and it'll do the actual AJAX request for you, behind the scenes.

This is basically what ASP.NET does too when you declare a [WebMethod]. Its simply a shortcut and might save time with maintenance, e.g. if your urls change I suspect DWR will update its client-side code too.

My only issue with this is that it seems to pollute the namespace.

To actually answer your question it does nothing you can't do with normal javascript and servlets.

like image 69
David Avatar answered Sep 23 '22 17:09

David