Chapter 1. The Google Web Toolkit s Approach to Ajax

Chapter 1. The Google Web Toolkit's Approach to Ajax

A developer will typically create his Ajax application by writing XHTML pages and JavaScript code with his favorite integrated development environment (IDE) or even text editors. A number of different libraries and frameworks exist by which programmers can use pre-designed JavaScript classes to implement otherwise time-consuming dynamic behaviors, such as drag-and-drop or sophisticated visual tree structures. These libraries include the Dojo toolkit, Prototype, the Yahoo! User Interface library, and They are designed for developers who are already fairly well advanced in their JavaScript knowledge.

These simple methods are changing as powerful tools proliferate for Ajax developers. The GWT takes a different approach to Ajax than most toolkits.

Using the GWT framework, you can design and program your user interface using only the Java language. You can use the GWT's command-line tools to check the syntax of the Java classes, then automatically generate the JavaScript for the application's client-side. The design of the user interface is very similar to using Java's Swing API.

You can thus view the GWT as a JavaScript-generation tool for Java programmers, as well as a framework for creating redistributable or extensible user-interface widgets. You do not have to know a lick of JavaScript, although you can include raw JavaScript in your code using special programming constructs that the GWT provides.

The GWT's benefits include:

  • You can use your favorite tools and existing knowledge to create sophisticated Ajax applications, often without segueing into JavaScript.

  • You can design and develop your application in a pure object-oriented fashion, since you are using Java. JavaScript does not have all of Java's built-in OO features.

  • Using the GWT removes many of the problems involved with adapting Ajax code to all the different browsers. These problems can represent real hairballs for developers, as two browsers may treat the same piece of code completely differently. You generally do not have to think about these potential incompatibilities while you are designing your application, except for testing your application in the various browsers afterward.

  • The JavaScript that the GWT compiler generates is quite obfuscated or very difficult to read, which provides your application with a low level of security or protection of proprietary material. You can "turn off" this obfuscation feature optionally, as this shortcut describes later.

  • Google and third parties keep adding libraries to the GWT, or making available ones that are interoperable with the GWT. These activities continue to extend GWT's features and reach. An example is an open-source library called the GWT Widget Library. This JAR file includes classes that wrap the Scriptaculous Effects objects, allowing you to add these interesting dynamic, visual effects to your GWT application. You can find out more about this library at

OK, enough of the high-level GWT discussion. Let's write a program and look at some code!

Google Web Toolkit for Ajax
Google Web Toolkit GWT Java AJAX Programming: A step-by-step to Google Web Toolkit for creating Ajax applications fast
ISBN: 1847191002
EAN: 2147483647
Year: 2006
Pages: 29

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: