Monday, February 09, 2009

DWR Hello World !

" 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. "

- Direct Web Remoting ( DwR )

I was snooping around for an AJAX library that I can use in one of my projects & narrowed down to DWR, after reading a lot of rave reviews about it. I was looking out for some AJAX library that'll allow me to call the methods in my Java classes with minimum effort.

I decided to take it for a test drive & check out the features. The usual sources were the DWR Documentation and Google.

I don't want to duplicate the good & decent documentation available for DWR at the "Get Started" page.

At a high level, I would like to just summarize the steps involved ( with the mistakes I made highlighted ) :-
  • Put dwr.jar in your Project's lib.
  • Put the Commons Logging Jar in your Projects's lib. ( Dwr uses Apache Commons Logging )
  • Add the configuration settings in your web.xml for the DWR Servlet.
  • Add the debugging parameters for the DWR Servlet during the development phase.
  • Add the dwr.xml under WEB-INF and configure it to expose your Java Classes.
  • Add the converters in dwr.xml to ensure the conversion of Java POJOs to JavaScript Objects & vice versa.
  • Include the reference to all the JavaScript libraries required in your JSPs.
Overall, I am impressed with this & I am going ahead with my implementation using DWR.

No comments: