I like to bring under your attention DWR – Easy Ajax for Java, a Java open source library created by Getahead. “Easy” is always good (like “free” is always good). The easiness of DWR is the principle that a Javascript method calls a server-side Java method: “It allows code in a web browser to use Java functions running on a web server as if it was in the browser.” An informative picture of this archtecture on the Getahead site is:
The DWR library consists of (1) Javascript and (2) a Java servlet (DWRServlet). This way implementing Ajax in a web page, feels like developing the client piece of a classic client/server application, like for example POOF (Plain Old Oracle Forms). In the figure above this simularity can be seen: when the event handler of a list item is launched, it calls a method on the server. In this example this is the getOptions method.
DWR can be integrated with JSF, Spring, Struts, Hibernate, Beehive.
So far this short notice. I took an example from the Getahead site and deployed this with maven on a local server. It is a bare minimal chatbox but that consists of just a few code lines(!) I added a weird clear button in just a minute. DWR is intriguing stuff to have a look at when you are interested in Ajax. Check out http://smnserver:8180/chat/ and http://smnserver:8181/svn/repos/chat/trunk.