about this book

Google Web Toolkit, or GWT, works on a simple but powerful idea. You write a web application in Java, and GWT cross-compiles it into JavaScript. This free, open source collection of tools is both supported and used by Google.

The latest version, GWT 2.5, includes a library of high-quality interface components, an easy-to-use UI designer, and a set of productivity tools that make using GWT a snap, and it supports industry-grade development techniques such as MVP, dependency injection, and event busses. And yes, the JavaScript it produces is really, really good, especially if you turn on the optional Closure compiler!

GWT in Action, Second Edition is a completely revised edition of the best-selling GWT book. It covers all the new features introduced in GWT 2.5, as well as the best development practices that have emerged in the GWT community. It begins with a rapid-fire introduction to GWT and Ajax to get you up to speed with GWT concepts and tools. Then, you’ll explore key concepts like managing events, interacting with the server, creating UI components, building your user interface declaratively using UiBinder, and more.

As you move through the engaging examples, you’ll pick up the skills you need to stay ahead of the pack. You’ll absorb the latest thinking in application design and industry-grade best practices, such as these:

Any substantial application requires server-side components, and many books can tell you about all the server-side development techniques (Java, PHP, and so on) for which GWT is highly flexible and which it can plug into. Our approach in GWT in Action is to concentrate several chapters on ensuring you get a thorough understanding of GWT’s client/server communication techniques. For example:

Although we don’t have a dedicated section on security, we do highlight GWT techniques as and where appropriate, for example, using SafeHtml when creating new widgets, manipulating the DOM, or using i18n; using SafeHtmlTemplates in Cell widgets; and protecting against cross-site forgery requests in GWT-RPC.

We’ve substantially updated and rewritten the examples from the first edition, splitting them into examples that focus purely on the topic of the chapter. Our hope is that these new examples give you a much more focused view of how to use GWT as well as show off what GWT can do. By breaking out into examples per chapter, it should be much easier to see the techniques in use and then employ them directly in your applications as needed.

Who should read this book

The book is aimed at anyone with an interest in

We appreciate that the readership will come from varied backgrounds—JavaScript programmers looking to see what the fuss is about or wanting, just as we did, to give better structure to their web applications; Java programmers learning that they can now program Ajax applications simply; server-side developers interested in understanding how GWT would affect them (it doesn’t have to); web designers looking to see how this useful development approach fits in with their approach (and to see how to guide programmers to use GWT’s built-in approaches to ensure their life is easier); managers/technicians looking to see how to get the web application beast under control; and many others.

In the first edition we spent a lot of time selling GWT itself. In this edition we no longer feel a need for that; rather we can spend the time on the exciting array of techniques and tools in GWT and get going more quickly.

Readers looking for an introduction to GWT concepts and components should find it in chapters 2 and 3. Here we go through using the tools to create a simple GWT HelloWorld application and show how to run in various modes (developer and super dev) as well as how to compile and debug problems. We then look at a more complex GWT application to show how to use concepts such as widgets, panels, history management, and styling. By the end of these two chapters, you should be familiar with creating a basic application, enhancing it to give some real complexity, as well as running/debugging the application in development mode and compiling it for web mode.

The middle part of the book covers techniques you’d use in everyday applications: building your own widgets, using client bundles, separating design from coding with UiBinder, communicating with the server in various ways, using widgets as editors, efficiently displaying/sorting/paging through large data sets, and interfacing with JavaScript (JSNI/fast JSON parsing with overlay objects).

More advanced readers will find that the book addresses the industry-grade approaches GWT supports that you may well have thought of but perhaps haven’t yet implemented—and we hope a few things you haven’t thought of yet! We cover MVP, dependency injection, deferred binding, generators, and using metrics and code splitting to squeeze out the most performant code possible.

You should be familiar with the concept of Java classes and packages, although we feel this is something you can pick up as you read the book, follow the code examples, and use an IDE, such as Eclipse. A lot of GWT (and Java) issues revolve around classpaths and GWT’s package structure, so we recommend a good read of chapter 2 if you get stuck.

Roadmap

Part 1 “Basics” consists of chapters 1 through 3. It aims to get you going in GWT and producing a first real-world example. We would suggest reading it in the order it is presented:

Part 2 we have called “Next Steps” and covers chapters 4 through 13. Here we discuss the usual technologies that you will often use when taking your application to the next level. You can read this part in order or jump directly to the topics that you are interested in:

Part 3 is “Advanced Topics.” In chapters 14 through 19 we cover topics that are more involved or complicated. As with the previous part, you can read in the order presented or dive into the chapters as you want.

Code conventions and downloads

The following typographical conventions are used throughout the book:

Source code for the examples in this book is available for download from the publisher’s website at www.manning.com/GWTinActionSecondEdition.

Author Online

The purchase of GWT in Action, Second Edition includes free access to a private forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and other users. You can access and subscribe to the forum at www.manning.com/GWTinActionSecondEdition. This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct in the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue among individual readers and between readers and authors can take place. It’s not a commitment to any specific amount of participation on the part of the authors, whose contribution to the book’s forum remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the title

By combining introductions, overviews, and how-to examples, the In Action books are designed to help learning and remembering. According to research in cognitive science, the things people remember are things they discover during self-motivated exploration.

Although no one at Manning is a cognitive scientist, we are convinced that for learning to become permanent, it must pass through stages of exploration, play, and, interestingly, retelling of what is being learned. People understand and remember new things, which is to say they master them, only after actively exploring them. Humans learn in action. An essential part of an In Action book is that it is example driven. It encourages the reader to try things out, to play with new code, and to explore new ideas.

There is another, more mundane reason for the title of this book: Our readers are busy. They use books to do a job or solve a problem. They need books that allow them to jump in and jump out easily and learn just what they want, just when they want it. They need books that aid them in action. The books in this series are designed for such readers.

About the authors

ADAM TACY is a digital channels client service manager for CGI based out of the Nordics with over 14 years experience in IT. He coauthored the first edition of GWT in Action with Robert Hanson in 2007 and has particular interest in how GWT 2.5 reduces the costs (development, maintenance, and management) of complex web projects while allowing the complexity boundaries of such applications to be aggressively challenged.

ROBERT HANSON is the applications development manager for Quality Technology Services and has spent over 15 years developing high-performance web applications. He released the first open source library of GWT tools and widgets in 2006 and coauthored the first edition of GWT in Action. Robert is also a member of the planning committee for the Philadelphia ETE conference, where he is a frequent speaker on GWT and other topics.

ANNA TÖKKE is a consultant for CGI Sweden with over 20 years of experience in IT development, the last 13 years as a lead programmer and solution architect. She educates developers in good programming practices and in object-oriented analysis and design. In recent years she has worked with GWT on a daily basis.

JASON ESSINGON is a Java software engineer for Calypso Technology with over 12 years of experience in treasury and financial industries. He has been an advocate of GWT since its public release and is an active member of the GWT community, contributing to both the mailing list and the GWT IRC channel.