Thursday, August 24, 2006

Profict Java Summer Camp - AJAX

I am just back from Profict's AJAX day, a very nice way of promoting one's company among developers. There were 2 speakers: Greg Murray, the AJAX architect from Sun and Bram Smeets, the DWR expert from Interface 21. In between there was a small product presentation from BackBase.

4 hours for Greg Murray
Four hours were filled by a jetlaged Greg. It seems that because he got so much time he could not chose what to tell from the many presentations he brought with him. It was a shame everything was so jumbled up because there were some really nice things in there. Without going into too much detail, here are some of the things he presented.

Greg is the main author for jMaki. jMaki is a small toolkit that allows you to wrap other Javascript toolkits (among others Dojo and Zimbra). jMaki comes standard with some nice widgets. Besides the usual datepickers and autocomplete stuff, there were some very nifty widgets that allow you write Mashups with Flickr, Yahoo Geocoder and Google Maps. A Mashup is a mashed combination of several web applications. One of his examples was a reworked Petstore where each pet was indicated on a map. jMaki is available for JSP and JSF environments. But given the raw components (simply a html, css and js file) you can probably include this stuff in any other framework easily.

jMaki also has some other basic stuff. For example an eventing mechanism (modeled after Dojo) and XmlHttpProxy. XmlHttpProxy is an XmlHttpRequest like feature that will allow you to call services in any domain by proxying the call on a server. This circumvents the security mechanism of Javascript in which you can only do HTTP requests to the domain from which the page was served.

AJAX, Back button and Anchor links
The trick of the day was the use of anchor links (the part after the #). When the user triggers an AJAX action (for example loading a different product), the URL of the currently loaded document is changed, but only in the anchor part. Since only the anchor changes, the browser will not reload the current page, but will add an entry to the page history. This means that suddenly the AJAX enabled page has a bookmarkable URL. In addition, much better back button support becomes possible.

Bram Smeets on DWR
The 1 and half hour presentation from Bram was a very nicely done introduction to DWR. In contrast to many other Javascript toolkits, DWR only provides communication between JavaScript and Java. However, as this presentation showed, DWR does so very well. In short, the idea behind DWR is that you can call a Java method directly from Javascript, and then can use the returned objects as if they are plain Javascript objects. If so desired, some utility Javascript functions can easily convert these objects to HTML and put them into the current page.

First an example was presented for DWR with plain Java and XML configuration. The few lines of Java and Javascript code on the slides showed that DWR is really a convenient thing to use. One of the killer features is a debug view of all exposed classes and methods. After a pitch style introduction of Spring, Bram then showed how to configure DWR from Spring. Though the integration is indeed nice, it gives you no advantages when you are not using the Spring bean container for some other reason (which of course there are plenty).

Reverse AJAX
The audience really heated up with the topic of Reverse AJAX (a.k.a. Comet, Long poll and for some even as Pushlets). This experimental DWR feature allows you to execute Javascript from Java. A very very neat example showed a method call on a Java-Scriptaculous 'impersonator' on the server side, with as result that the Scriptaculous effect is applied in the browser. Unfortunately Reverse AJAX is still at an experimental stage. As Bram told me later, this is mainly because it has not been tested properly in many circumstances. In addition, you must be very aware of the load this brings to your server.

The day ended with a nice barbecue in the beautiful garden of Profict's castle.


  1. I think it's to bad most presentations on AJAX seem to be a bit superficial. The presentation on DWR you describe sounds very similar to the chapter in the Spring MVC book.

    Complex problems like cancelling open requests, browser compatibility (yes this is STILL a huge issue), fallback to non xmlhttp based solutions and interaction design are often skipped...

    I do however really like DWR, it is well focussed and seems to just work.

  2. Given the amount of time, the presentations were rightly, but only slightly beyond superficial (well, except for the really short BackBase presentation).

    Though Greg's presentation focused on the widgets in jMaki, he did list the transport technologies (XMLHttpRequest, hidden frame and script tag includes) and the common protocols (XML, JSON, etc.). Both Dojo and DWR support the first two transport technologies.

    Greg mentioned Dojo's ability to show a 'loading' message. No other interaction design issues were mentioned. Peter, can you name some?

    The DWR presentation was definitely better then the DWR chapter in the Spring MVC book. The book only shows an example. The presentation also made you understand it. In addition Bram showed some of the less used features and some newer stuff.

  3. Ah, thanks for elaborating ;)

    Most interface designers (more specifically webdesigners) seem to have a hard time designing a good interface with the endless possibilities introduced by the countless number of frameworks.

    Also designing the interface to be 'degradeable' for non-ajax browsers (i.e. blind people using screen readers, and crawlers) seems to be quite a challenge.

    Consistency between different applications is another problem....
    People often complain about the inconsistency of applications for linux; they rave about inconstent ajax apps all the time....

    'integration' Toolkits like jMaki seem to be in a perfect position to enforce standarization of interface components and look&feel. But, correct me if I'm wrong, not much seems to be happening on this front.

    I discussed the above with one of the Backbase guys a while ago, but it seems Backbase doesn't have any interest apart from a commercial one. Shame on them ;)

    I'm still waiting to see a good presentation on AJAX best practices. Not only technical but also stuff like division of roles/tasks in dev teams,
    testing (different browsers, different security settings in browsers, degradeability, handling of timeouts etc.). I know a couple of testing frameworks for AJAX, but all are far to complex and timeconsuming to fit into most projects I know of.

    Concluding: I know which stuff is availlable, I know how it works... but found it to be the most complex part of my recent/current project (due to the above) to manage.
    Now how DO you sensibly use AJAX on a project without going over budget?

  4. O.k. just after typing my previous post I noted this announcement on theserverside:

    a conference with a couple of sessions on the topics I mentioned. To bad it's located in Boston!