You are hereBlogs / meck's blog / GWT - Not just another way of creating Websites...

GWT - Not just another way of creating Websites...


By meck - Posted on 18 July 2007

Google Code LogoHi everybody! Today I will talk about the GWT (Google WebToolkit). I have been using it for about one year now (not all the time), and I am now at a point where I can say, that I have a basic impression on how stuff is done or at least can be done. In this article I want to summarize what beginners with the GWT will probably face and give some (hopefully) useful hints.

For those of you who never heard of the GWT, I start with a short introduction. It is a tool/framework which lets you create AJAX websites without coding any line of JavaScript. Therefore it provides a compiler which transforms the client side of your project that is executed by the browser into JavaScript. You as a programmer just have to write Java code. You are restricted on the classes you can use on the client side though.

So what is the big picture of a running GWT application? On the client is JavaScript doing most of the application logic directly without bothering the server. More complicated tasks however can/must be done on the server side which consists of nothing less than a full featured Java Application Server like Apache Tomcat. The gap between the client and server side are overcome by using the GWT built-in RPC calls.

Sounds like a complex architecture... and in my opinion that's true. There is a lot to set up and configurate to get things working. Google provides a very easy start for beginners though. If you just want to see what the GWT is like, go to the website, grab the archive for your platform, unpack it and start by executing the skripts in the examples subfolders. It will bring you up the example applications in a Tomcat instance shipped by the GWT. That's all a thing of 5 minutes I would say.

Problems start when you try to build your own application from scratch without using the Google provided scripts. For most people it is also not possible to use the shipped Tomcat as they already have their own instance already running on a webserver. Configuration can be really complex and misconfiguration can lead to wired error messages. Especially the use of RPC calls introduces a new level of complexity. To make your first GWT experience a good one, I therefore strongly recommend:

  • Start a small project and put it under version control so that you always see which files are generated by the GWT.
  • After playing around a little bit try to get an external Tomcat running and use Apache Ant to set up a build system.
  • If your build system is generating a war file and deploying successfully, you can know start to introduce RPCs. Note that you will probably have to adapt some config files to get it working.
I personally managed to set up a GWT project with an external Tomcat using a database and the whole stuff. My build process is totally managed by Apache Ant without the GWT provided scripts. Everything compiles on Windows, Mac and Linux. Quite a lot work had to be done to manage that and a small article like this could never cover all my problems I had, so I will not try to write a tutorial here about the whole setup. Nevertheless feel free to comment and ask questions!
Cool stuff, man. I might come back to that first point you made there about putting the whole gwt project under version control. I never really knew how to do that, as GWT "ships" different versions for differing platforms, and I really wasn't sure how to elegantly only put the project-specific items into subversion (I would like others to somehow elegantly be able to compile my project as well). Sounds like something we should discuss over some Mensa food.