Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Some Recipes to Improve Your Google Web Toolkit Development

Experiences, tips and techniques to assist you in creating GWT Web applications.

  • Print
  • Feedback

According to Google's announcements on the GWT home page, GWT makes writing AJAX applications easy for developers "who don't speak browser quirks as a second language". Starting with version 1.3.RC in December 2006, GWT is 100% open source under the Apache 2.0 license; at the time of this writing we have version 1.3.3 as a stable release. The heart of the toolkit is its GUI library with the Java-to-JavaScript compiler, the asynchronous remote procedure call (RPC) and object serialization mechanisms, and the full debugging support for client and server-side code when working with an IDE like Eclipse or IntelliJ's IDEA.

Lots of introductory material has been published about GWT since its early days - primarily as world-wide web articles and tutorials (e.g., Jeff Hanson's JavaWorld article, see Resources) - we can now read whole books about it. Therefore, in this article I will not discuss subjects like what GWT is all about or how to write a currency converter with GWT. But rather by looking not only at the UI client-side aspects of GWT, I will try to give you some tips, sometimes some tricks, and also some issues to think about when you start coding -- even before you start creating your project structure and environment. I hope you can profit by my experiences implementing a GWT web application from scratch, and then doing a lot of refactoring, redesign and restructuring to make my life simpler and the application user feel better.

GWT Development Lessons Learned

After writing several hundred lines of GWT- and GWT-related servlet code for Tomcat I would not claim that I'm a GWT guru, but as outlined in the abstract, I try to present some problems and solutions that are not covered by "getting started" tutorials and articles. I will assume that you are familiar with Java, GWT and servlet basics and with tools like Eclipse, Ant, and JUnit.

Of course, I cannot cover every possible GWT topic here, that would break the context of such an article, and - to be honest - I have not used all major GWT features in my case study; so, e.g., I have no practice with GWT security aspects or internationalization. However, the following eight tips will address some typical areas in developing, testing and deploying your GWT applications, assuming your server part is covered by servlet technology.

Tip 1: Divide and conquer

We all know, GWT applications are Java applications. However, the point is "which Java"? We have to keep in mind that GWT compiles Java sources that are compatible with J2SE 1.4.2 or earlier! Furthermore, only a subset of the J2SE 1.4.2 APIs is supported, namely the java.lang and java.util. package. Even when working with these packages you should study Google's remarks on runtime library support (to be found at the GWT home page) very carefully and take the corresponding tip to heart: "You'll save yourself a lot of frustration if you make sure that you use only translatable classes in your client-side code from the very beginning. To help you identify problems early, your code is checked against the JRE emulation library whenever you run in hosted mode. As a result, most uses of unsupported libraries will be caught the first time you attempt to run your application. So, run early and often."

  • Print
  • Feedback

Resources

Google Web Toolkit home page

GWT Unofficial Wiki page

Introduction to GWT development: Ease AJAX development with the Google Web Toolkit

GWT add-on for debugging, developed by Mat Gessel.

GUI-based GWT testing with Selenium

For a good Ant script to deploy your GWT applications to Tomcat see: Google Web Toolkit: AJAX Buzz Meets Real World Development

Groovy Gant

To get the Gant script and the corresponding build.properties file for easy GWT deployment to Tomcat, download sample code.