Thursday, August 5, 2010

Introduction to GWT

This is the Part 1 of what I expect will become a series of articles about my personal experiences when developing with GWT.

Some months ago I started a project with GWT for my current employee. This was my first GWT project, so I needed to do some research and quite a lot of proof of concept, to make sure I could cover all the requested features.

What’s and what’s not GWT

That’s what Google says about GWT in their official page. 
Google Web Toolkit (GWT) is a development toolkit for building and optimizing complex browser-based applications. GWT is used by many products at Google, including Google Wave and Google AdWords. It's open source, completely free, and used by thousands of developers around the world. 
In this paragraph we have the first key about what’s GWT “is a development toolkit for building complex browser-based applications”. GWT is not the toolkit to use in your homepage or a simple website. For those tasks it’s much better to use pure Javascript toolkits (like JQuery) or maybe some PHP backend. 

GWT is useful when you want to create complex enterprise browser-based applications. But “what’s a complex enterprise browser-based application”? 

Well, I imagine that really depends, but I would say that any browser-based application that requires support for multiple simultaneous users, access to some backend with complex rules and wants to use a rich user interface. 

GWT only solves the rich user interface part, but is a perfect complement for a J2EE backend, allowing an easy integration and a rich experience. 

How is different GWT from other web toolkits? 

I would say that the most important difference is that when developing you only need to known Java, there’s no need to known anything about HTML or Javascript (even when it helps when you need to do really complex features) 

Ok, but JSP or IceFaces/RichFaces also allow to do that. Yes and no. JSP is the Java equivalent to PHP. That means that you need to known HTML and Javascript and inject the PHP in the middle. IceFaces/RichFaces are a really good alternative. In fact I almost choose IceFaces for my project, but the widgets and the flexibility of the components where not matching my expectations. 

Why should I choose GWT? 

For me GWT was the correct solution due to multiple factors:
  • Google is putting quite some efforts in this toolkit and the community around it is really active
  • GWT can be easily customized using CSS and even with direct DOM interaction
  • There are some really interesting extensions for GWT
    • GWT-Cal: Covert one of my main requisites and the developers are really friendly and helpful
    • GWT-Mosaic: Perfectly complements some missing feature and widgets in GWT
    • GWT-Log: Nice and easy integrated logging system
    • GWT-DND: Wonderful Drag&Drop API
Is everything that good? Really?
Well, not really. When I started my project I used SmartGWT. At the beginning it was awesome, everything was really simple, tons of widgets and a lot of people giving good reviews.
I was decided to use it, in fact I even started my project using SmartGWT, but not everything was that perfect.
When using SmartGWT I started finding problems, some were more annoyances than bugs, others required tons of extra work. My first disappointment came from the lack of help in the official forums. In fact I was even surprised by the hard reaction of some of the developers with some users questions. The next problem came when I tried to modify the theme. Was a complete nightmare, everything seemed like a problem and I found myself investing too much time in something that should be really simple.
By then I knew enough to create my own components and libraries like GWT-Mosaic only made everything easier. So I took the way that I wanted to avoid using SmartGWT, but at the end was easier than expected. And now I could use simple CSS and PNGs to create my UI.
Here I finish the first part of these tour through GWT. As you saw GWT is easy enough to use, but powerful enough to tweak it as you want. The ecosystem of libraries is rich enough, but keep always in mind what to you want to achieve.
In the Part 2 I will show you how to create some nice effects and widgets in GWT.
See you soon.


  1. good article, thanks)

    always thought that GWT is not perfect :)

  2. Nice Article. Thank you .. Please write more such articles that inspire us :)

  3. Thanks a lot for your positive comments :)

    For sure I'll write more articles, hope you'll like them too ;)