Back to the blog home page Subscribe to our RSS FeedView our Facebook PageFollow us on Twitter width=View our YouTube ChannelVisit us on Foursquare WMpS Main Site
Aug 17, 2010

Posted by Wei Shao in Website Build | 0 comments

Why Use GWT for AJAX Applications?

Why Use GWT for AJAX Applications?

AJAX is a very attractive technique for many web developers. It allows users to interact with your site and communicate with your database without refreshing the pages. However, owing to their dynamic nature, Ajax interfaces are often harder to develop when compared to static pages. In order to reduce the complexity of development, people have started to build up some libraries to support AJAX, such as JQUERY and GWT.

Beginning with AJAX

AJAX (Asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client side to create interactive web applications. Ajax allows web applications to retrieve data from server asynchronously in the background without interfering with the display or behaviour of the existing page.

internet chart

The preceding chart shows how Ajax works. The browser listens to the event and creates an XMLHttpRequst object when the event is triggered. XMLHttpRequest object is the object that used to communicate between server and browser instead of HttpRequest, which would refresh the whole page. Most modern browsers have a built-in XMLHttpRequest, but IE6 and many earlier versions don’t support this object.

If there is only one Ajax application on your page, the above concept would be easily implemented by couple lines of simple JavaScript codes. But when your project includes large Ajax usages such as Google Docs, or Google Wave, it can be very difficult to manage your JavaScript.

Google Website Toolkit

GWT (Google Website Toolkit) is a set of tools that can compile the Java source code to JavaScript. In other words, web developers can create and maintain complex JavaScript front-end applications in Java. Also, GWT supports many ways to communicate with a server. All of these are asynchronous, which means all GWT application would be all AJAX-based.

The Benefits of Using GWT

GWT is a Java environment, which is well known for its clear object concept and easy maintenance.  While in development, you can run your Java code in a special “hosted mode” browser with all of the mature, sophisticated Java debugging tools you always have available.

GWT support many ways to process asynchronous communication between the browser and the server. One of them is the RPC mechanism, which defines interfaces and implementations for the server functions, and code will be generated to allow your client code to call them as if they were simple local methods. This replaces defining XML or JSON data formats for requests and responses.  Meanwhile, GWT also support the JSON and XML over HTTP.

Almost all AJAX developers have suffered from writing JavaScript to support all browsers. GWT, like any other good AJAX framework, will handle this for you.  The GWT has a built-in GUI library that would allow you built a web application like swing and swt. All of these would be able to transferred to standard HTML and be embedded into your site.

More importantly, GWT applications provide true interactivity with lots of code being executed on the client, reducing server-side interaction to a minimum. As a result, it provides very good usability and enhances the user experience.

Summary

There are lots of good reasons to choose GWT, and these are just scratching the surface. With the increasing popularity of cloud computing, more and more applications are on track to become web-based. GWT would be a very good framework to help you build your “real on-line application”.




Leave a Reply

Follow WMpS on Twitter