2006-01-05

AJAX Tech Talk

I attended a talk on AJAX by Greg Murray (Lead Engineer at Sun; also Servlet specification lead) last night at the Stevens Creek Barnes & Noble in San Jose. Here are my brief notes from that presentation (see http://java.sun.com/blueprints/ajax.html for Sun's main page on AJAX).

Advice: Choose a framework / library and use it. Don't re-invent the wheel.

Interesting applications:

  • Intercepting the "back" button (Dojo can do this) and making it operate like "Undo" in a GUI.
  • Single page application, but updating the address bar (without page reload) with a permalink that would return to the same or a similar page if bookmarked or shared with another person.
    (I think this is particularly interesting because it could be used to hide a session id from the user, but still pass it to the server in the URLs used for AJAX requests.)

Advice: Be careful about Section 508 compliance, especially if you sell or intend to sell to the U.S. government. It can be difficult to meet these accessibility rules with AJAX applications. You may even have to maintain two different applications: One with a great dynamic user experience built with AJAX, and another, simpler user experience suitable for screen readers.

Development notes:

  • Use encodeURI() in JavaScript for building URLs and sending localizable content to the server
  • Use UTF-8 for page character set
  • If implementing your own autocomplete text field (like Google Suggest), be sure to set the (nonstandard but well supported) autocomplete attribute of the input element to off to keep the browser's own autocomplete mechanism out of your way.
  • In your Servlet, set the character encoding to UTF-8 on servlet request before accessing parameters
  • Can send data back to browser via text, XML or JavaScript to be sent to eval() (JSON)
    (I think it would be interesting to have a SAX consumer that spit out JSON so code that used SAX to generate XML could be easily used to generate JSON too by plugging in a different backend.)
  • Browsers vary in support. Mozilla browsers and Internet Explorer are pretty good (although using a framework isolates you from their differences). Safari and Opera have some issues.
  • Some work is going into standardization
  • Don't forget (this isn't new): HTTP GET is for times when the request will not change state on the server. HTTP POST is for times when the request does change state.
  • Weblets: Packaging for web application resources
  • Some people are looking at ways of storing more data on the client side, including for offline operation of AJAX applications (AMASS is one).

Debugging notes:

Other Web 2.0 ideas:

2 comments:

Gregor Purdy said...

[[ IMPORTING OLD BLOG COMMENT FROM "bbum" <bbum@mac.com> at 2006-01-09 11:28 AM ]]

You should have a look at MochiKit (google knows all). I have heard really great things about it and know Bob well from his top notch work on PyObjC.

Gregor Purdy said...

[[ IMPORTING OLD BLOG COMMENT FROM "shankar" <shankar_uprety@yahoo.com> at 2006-03-15 05:01 AM ]]

can you provide me an example how to updating the address bar (without page reload). And also interception the back button