
eveloping AJAX applications is really hard, because few developers have a complete grasp of JavaScriptthe language of AJAX (Asynchronous JavaScript and XML). Making matters worst, every browser has idiosyncrasies in its JavaScript implementation, which introduces incompatibility nightmares (See "
Sidebar 1. Web UIs of the Past and AJAX's JavaScript Underbelly"). The almighty Google, which glorified AJAX with Gmail and Google Maps, has come to the rescue with the Google Web Toolkit (GWT).
| What You Need |
| Google Web Toolkit |
| Apache Ant 1.6 |
| Apache Tomcat |
| Java Standard Edition 1.4 or higher |
| Eclipse |
Google Promotes AJAX with Web Toolkit
Google used AJAX in its Gmail and Google Maps applications. You can be sure developers at Google weren't thrilled about using JavaScript, but that wasn't about to impede the search giant. Google applied a technique that has been prevalent since the early years of computers: the quintessential compiler. Compilers have enabled developers to develop/code in higher-level languages that they easily understand, since the compilers will convert them to a lower-level language that computers understand.
A small team at Google created a Java-to-JavaScript compiler that takes in Java code and spits out JavaScript, enabling the Google developers to design, develop, debug, and test in Java and leave the compiler to deal with the vicissitudes of JavaScript. Heeding Google's 'Do No Evil' motto, the team decided to share its technology freely with the developer community under the name Google Web Toolkit (GWT).
In addition to a compiler, GWT comes with the following panoply of APIs and tools that are sure to alleviate AJAX development pains:
- Scripts that create starter files for your application
- User interface widgets and layout managers that you develop in Java and then compile to JavaScript via GWT
- Java components that enable RPC communication between JavaScript client and server
- History events and functions that respond to the browser history stack
- A GWT-hosted environment that enables debugging in the Eclipse IDE
- The GWT compiler (of course) that coverts user interfaces and RPC Java code to JavaScript that is compatible with IE, Firefox, Mozilla, Safari, and Opera
This article provides a hands-on demonstration of all the above features. Along the way, you will see how to use GWT with Apache Ant and Tomcata still nascent area in GWT.