Which Open Source AJAX Framework is Right for You?
Developer and Architect
So you've decided to use AJAX in your next project. AJAX is a hot technology and some solid AJAX experience would certainly look good on your resume. Your main challenge is to get this evil plan implemented and the code working before your pointy-haired manger notices and puts a stop to your fun.
The good news is that AJAX technology has matured to the point where there are many good frameworks that will make this plan a success. The tricky part is choosing the right AJAX framework for your project.
To help you make just the right selection, we have prepared this review of several popular frameworks and recommendations for determining which one is right for your project. Let's get started with some context on AJAX technology. We'll then look at some popular frameworks and our recommendations for the best use of each framework.
Adopting AJAX presents some good news and bad news. The good news is that your users will have a smile on their face. AJAX adds the responsiveness of a desktop application to web applications. Without AJAX every user input requires a lengthy round trip from the browser to the server reminiscent of a late '80s mainframe terminal. With AJAX you can selectively update portions of the current page without reloading the entire page. Sure, the browser still needs to complete a request and response cycle to the server, but this work is done asynchronously on a separate thread without blocking user interaction. And that's where the bad news crops up.
Programming an asynchronous application is more complex - a callback (response) resulting from a request can come back at anytime. This problem maybe more familiar to anyone who has developed a GUI. The widely used tactic is to adopt an event driven programming model. This is all easy enough when you have useful objects such as events, event listeners, and cool widgets ready for use. However, the built in support for AJAX in browsers is much more low level and harder to use.
If you start a new project, it is very suitable to pick an AJAX framework that provides both client and server side support. However, if you are adding AJAX to your existing project, you may want to pick an AJAX framework that can easily integrate with your existing code. Adopting a client side AJAX library is a great option if you want to minimize changes to your existing code. Some frameworks also provide server side support that allows reuse of existing code.Another factor to consider is your skill base. If your framework choice is based on an unfamiliar language you may spend a lot of time learning the new language. There are many frameworks available and it is quite likely that you can find a suitable framework that will make the most of your programming skills.
Client Side Library
Figure 1. Context Diagram for an Ajax application which shows a client side library and a server side framework.
Besides the typical API for handling AJAX requests, Dojo also comes with a long list of widgets you can use immediately. Out of the box, Dojo comes with complex widgets such as a slider, datepicker, googlemap, menubar, toolbar, tree and etc (here is a complete list). Widgets supported by Dojo have an event system which allows interaction with other widgets on the same page. Also, Dojo provides excellent support for object oriented programming such as class methods and properties, multi-level inheritance, and also implements aspect-oriented programming concepts.
JQuery has a very lightweight footprint (< 20KB in size for download). If your project requires quick page loads JQuery will not be a burden. JQuery also focuses on code conciseness so code using JQuery tends to be dense. However, it does not support a reusable programming model like an object oriented approach, so you should not expect thousands of lines of JQuery code to be a good asset to your project (unless you're not the one who has do the maintenance).
Server Side Support Framework
If your project is Java based, DWR provides a great option for allowing your new AJAX GUI to interact with your existing server-side Java objects.
For Java developers, Struts is the most widely used open source web application framework. Struts 1 is so popular that it is virtually the standard for Corporate J2EE application development. Struts 2 adds built-in AJAX support based on the Dojo toolkit.
Choosing Struts as an application framework is a very safe choice as many large scale sites are based on Struts, er, Struts 1 that is. Struts 2 was released for general availability in February of 2007 and is complete re-write of Struts 1. It is Apache software which is typically of high quality. However, you may want to wait a little while before basing a major project on Struts 2.
This is seems like a scary idea but it turns out to be the best of both
worlds. Java has a really strong tool chain. You can use your
favorite IDE (Eclipse or Net Beans) and even debug the application using a
Java debugger as the application runs in a JVM during development.
Integration to server side Java code is very easy as GWT supplies Real Simple
RPC that automagically allows passing of Java objects between the browser and
the application server. The other great feature is that the compilation
GWT is a natural choice if you are starting a new project and have good Java
skills. Your productivity will be high right from the start.
Ruby on Rails is a very popular web application framework that has native support for AJAX. Ruby On Rails is known for having a low entry barrier and small footprint. Ruby on Rails is based on convention over configuration. For anyone who has spent days pawing through XML application server configuration files, this is a true selling point. You do have to know that Ruby as it is the scripting language which Rails is based on.
Rails is an excellent choice if you are starting a new project. You'll have to assess if your team has the language skills or is willing to learn Ruby. If you do make the leap chances are you'll be raving about Rails' ease of use.
on the server side? This is the thinking that has lead to Phobos.
Phobos is based on the
Server side frameworks are best when embarking on a new project and you don't have to integrate with an existing code base. Adopting a framework can really boost your productivity. The alternative of building you own infrastructure will be harder and take longer.
Adding AJAX components to your next project is a great idea. You'll quite likely end up with an easier-to-use product and your customers will like it better. We've suggested a few interesting frameworks here; there are many others available. Take the time to select and adopt a framework to make your next project a success.
About the authors
- Jeff Szeto is a developer and architect with over 15 years of experience in enterprise application development. He is a Sun Certified Java Architect and Programmer and holds a Masters degree in Computer Science from Virginia Tech.
- Marty is a Principal Consultant with Beaver Creek Consulting Corp. Marty has 10 years of professional experience as a Software Developer and specializes in developing finance and accounting solutions. Marty is a Sun Certified Java Programmer with expertise in J2EE and database systems. He holds a Doctorate in Chemical Engineering from the University of Virginia.
This article first appeared at MrBool.com at: http://www.mrbool.com/articles/viewcomp.asp?comp=5311
Last Update: 20070510