Chapter 6. Ajax Libraries and Toolkits

When the term Ajax was first coined, many developers were surprised by the power of JavaScript. They had been using JavaScript for years but hadn’t figured out that they could use it to create web applications with functionality that rivaled that of native desktop applications. That “eureka” moment led to hype, which in turn created the energy that has allowed Ajax to mature. When Ajax was getting started, developers had to build their applications without any help (as we have done in the past few chapters): they had to write all the JavaScript, parse the XML or JSON by hand, and create servlets to handle the asynchronous interaction with the client. That’s no longer the case. The number of frameworks that exist now to simplify the task of creating Ajax applications is solid proof that Ajax is more than just hype: it’s a valid, thriving architecture.

All I can say is, “Cool, bring it on!” As web developers, we have waited a long time to bring this functionality to our web applications. Swing developers, beware: Ajax levels the playing field.

Up until now, we’ve been building our Ajax applications with XMLHttpRequest. We have used XMLHttpRequest to send requests to the server, and we have set up callback methods to intercept the responses coming back from the server.

We can make that portion of our code more resilient by using libraries. An Ajax toolkit or library can help us build the request object and set up the callback function. Using a toolkit ...

Get Ajax on Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.