Subscribe to our RSS feed!

AJAX And The Google Tool Kit

First things first, Asynchronous JavaScript and XML (AJAX) is not a technology. AJAX is a technique that has brought about a great change in the world of web development.

The AJAX technique comes in response to the increasing demand of interactive web applications. With AJAX, web pages exchange small amounts of data with the server behind the scenes. This means that every time a new piece of data is entered by the user, or there is a request for a change, the entire page does not have to be reloaded. Usability is also greatly affected thanks to AJAX. After all, AJAX creates conditions that are conducive to a complex scenario that is both data-centric and user-centric. The difference between web pages and other applications has been thinned down with the help of AJAX.

As already mentioned, AJAX is not a technology and this technique fuses together various existing technologies such as XHTML (or HTML), CSS, the DOM, XMLHttpRequest (or alternatively IFrame), and XML.

Here is how these individual technologies play a role in AJAX:

* XHTML (or HTML) and CSS are used for mark up and styling information.

* The DOM (Document Object Model) is employed for the actual interaction that happens with the information that is presented.

* The exchange of data asynchronously with the web server happens with the use of XMLHttpRequest. Although there are many cases where an IFrame object is used in its place.

* Even though even preformatted HTML would work, XML is the format often used for the transfer of data between the server and the client.

The advantages and disadvantages of using AJAX are in fact open for interpretation. Here are some of the reasons that are cited as advantages of using AJAX.

* The main reason for using AJAX is to enhance the user experience, and to make web pages behave more like standalone applications.

* AJAX enabled pages load faster because it generates HTML within the browser. The net result of the page loading in a staggered manner is the bandwidth consumption for a web page is considerably reduced.

* The third advantage is widely critiqued because of a common misconception about AJAX - that it is a mix n' match of various techniques, not leaving room for any consistency. Yet with AJAX programmers tend to create a distinct separation between the methods and formats that are employed for the purpose of information delivery. In other words separation between the content that is to be delivered, the structure and style elements of the webpage, and the functionality of the webpage.

On the flip side are the disadvantages that people associate with the use of AJAX.

* Given that, with AJAX, the page does not register with the history engine of the browser, the user is often unable to use the 'Back' function of the browser. Additionally, AJAX also makes it difficult for users to 'Bookmark' a page at a certain stage of use. The solutions created to tackle these problems have not been adequate, and these issues remain unresolved for the most part.

* The possible delay between user request and server response, is an obvious drawback of AJAX. This lag, known as network latency is made worse by a phenomenon that has nothing to with the technologies involved. When a page is rendered in entirety the human eye naturally re-adjusts itself to identifying the changed elements of refreshed page. On the other hand, when smaller portions of the page are rendered individually the user may not see the change immediately and imagine latency when it in fact does not exist.

* Another possible problem is that search engines cannot execute the JavaScript that is a part of the AJAX functionality. It is important to note that this particular problem is not restricted to AJAX.

* Yet another issue with AJAX is compatibility. JavaScript, which AJAX depends on, may be implemented differently by different browsers.

At the face of it, the disadvantages seem to weigh over the advantages making AJAX seem a less viable option for developers. There is no doubt that AJAX is complex, and there are still not many developers who are acquainted with its language. Yet a change has been brought about with Google slotting AJAX in their applications.

Google's move is a landmark event in the web development arena. Google applied compilers to help them carry out this mammoth task. Compilers give developers the chance to code/develop in a higher-level language, which it converts to a lower-level language which the computer understands. A Java to JavaScript compiler was created so that developers could work in the former and leave it to the compiler to convert the same into the latter. This technology was freely shared with the developer community and is known as the Google Web Toolkit (GWT).

The GWT development cycle is rather straightforward:

1. Use Java to design, develop, debug, and test. In this process you may or may not choose to employ GWT libraries that seem of use. You are free to use any of the Java tools that you feel comfortable with - Eclipse, IntelliJ, JProfiler, JUnit.

2. Use the GWT's compiler that distills the application from Java to a set of JavaScript and HTML files which can work with any web sever.

3. Ensure compatibility of the application with the browsers you want to support.

GWT can be run in two modes - hosted mode and web mode.

Hosted mode: Most of the development time ordinarily would be spent in this mode because since your application is run as Java byte code within the Java Virtual Machine (JVM), you can have the benefit of employing the debugging facilities in Java.

Web mode: In this mode, the application is run as pure JavaScript and HTML

If AJAX is meant to ease the surfing experience of users, GWT is meant to ease the process of developing to the farthest possible limit. And GWT has made it easy for developers to use AJAX for creating applications. For instance, common errors that occur with JavaScript such as typos and type mismatches can be identified at the time of compilation. There is often a conflict between what is easy for developers to do, and what is beneficial for users. This conflict, needless to say must end in the favor of what is beneficial for users. And the net result of using GWT and making things more convenient for developers would of course a better web experience for users.

The main features of the Google Web Toolkit are:

* Even though, unlike traditional HTML web applications, GWT applications do not need to fetch new HTML pages as they execute, they do in fact need to get data from the server. Also referred to as a server call, this mechanism is better known as Remote Procedure Call (RPC) and enables interaction with the server across a network.

* The presence of dynamic and reusable UI (User Interface) frameworks. The key difference between UI frameworks in GWT in comparison to others is the way widgets (Java classes on the client-side that are used to build user interface) are rendered.

* Full-featured debugging in the hosted mode.

* Allows for the appropriate management of browser history.

* Automatic compatibility with different browsers is yet another attractive feature of GWT applications.

* Yet another feature of the GWT is that it helps you internationalize your applications and libraries.

* GWT allows you to unit test in a debugger and browser.

* With the help of the JavaScript Native Interface (JSNI) you can add handwritten JavaScript in the Java code.

* The most important feature of the GWT is the fact that it is completely open source code.

For the uninitiated, all this sounds too technical. But the very purpose of GWT is to extract developers from the web of technicalities and give them space to create something that speaks with their end-user. And the demand for interactive spaces online is only going to increase.

The AJAX trend is catching up and thanks to GWT developers are able to slowly but surely get over their initial apprehensions about the difficulties that AJAX poses.

The role of developers in the development lifecycle of a web application cannot be undermined, but with AJAX enabled GWT their role actually ceases to be just that of typing together back-end operations.

Google Maps is an excellent example of the advantages of working with AJAX within the GWT framework. Google map is definitive example of something that is dynamic, attractive and completely user-friendly. Finding locations and using functionalities such as zoom in/out instantaneously is a tremendous advancement.

Imagine, having to interminably wait for the page to reload when you click on a location or search for it in the search bar? The very purpose of having the map would be defeated, if it was going to take just as much time to look for a specific location online as it would on a printed map. There are some detractors who say...

AJAX enabled GWT is the practical way forward. End-users hardly take this for granted, but the work that goes behind creating this ultimate user-experience pays off. And indeed, GWT has made ease of development possible without losing out on user-satisfaction. With techniques like AJAX, and systems like GWT the future of web development is one that holds a lot of promise for users and developers alike!

Tag: ,

AddThis social bookmark button

Bookmark and Share

About the author:
Munish Dev Rathee is currently working for redrain solutions which is an web design company functional in India.
Get Your Site Submitted for Free in the World's Largest B2B Directory!

*Mandatory Field
* *

AJAX and the Google Tool Kit