GWT in Action
Adam Tacy, Robert Hanson, Jason Essington, and Anne Tkke
Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email:
orders@manning.com2013 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
| Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without elemental chlorine. |
| Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 |
Development editor: | Jeff Bleiel |
Copyeditor: | Linda Recktenwald |
Technical proofreader: | Levi Bracken |
Proofreaders: | Tara Wlash, Tiffany Taylor |
Typesetter: | Marija Tudor |
Cover designer: | Marija Tudor |
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 MAL 18 17 16 15 14 13 12
Dedication
To my parents. Simply, thank you once again, for everything.
A. Tacy
To my father. Thank you for every computer and video game you bought me when I was a kid. Without them I would have never found my true passion in this world.
R. Hanson
To my wonderful husband Peter and daughter Elektra. Thank you for allowing me the time to do this. Love you both.
A. Tkke
Brief Table of Contents
Table of Contents
Praise for the First Edition of GWT in Action
The thoroughness with which the authors designed examples to illustrate every concept dealt with in the book, and the scope of the topics addressed in it, make GWT in Action a valuable addition to any web developers library.
JavaLobby.com
...GWT in Action is packed with practical information on a wide range of GWT topics.
Michael J. Ross, Slashdot.org
How to think in GWT. The code: concise, efficient, thorough, and plentiful.
Scott Stirling, AT&T
Impressive quality and thoroughness. Wonderful!
Bernard Farrell, Kronos, Inc.
Perfect for Java developers struggling with JavaScript.
Carlo Bottiglieri, Sytel-Reply
A real nitty-gritty tutorial on the rich features of GWT.
Andrew Grothe, Eliptic Webwise, Inc.
I was very impressed with the quality of the writing as well as the depth of coverage. The authors explain the examples well and it is easy to follow them.
YongSung Kim, Amazon reader
Preface
Since the first edition of this book, the Google Web Toolkit (GWT) has grown, transformed, and emerged from a promising toolkit for web applications into a toolkit that truly supports 1) developers and managers in delivering web applications that can push the boundaries of the possible and 2) the application of well-tread engineering principles (deliver better user experience while reducing your development/maintenance costs).
This second edition of GWT in Action builds on our view of the first edition. Its fully updated to look at the latest version, 2.5, of GWT, covering all the new techniques and toolswe even take a sneak look at the experimental items (such as super dev mode and the Elemental library). Perhaps the largest change between editions is that each technique is demonstrated with individual examples, rather than the monolithic example from the first edition. We hope this allows more focused examination and offers a simpler Ctrl+C/V mechanism to get those techniques into your own applications.
We said back in 2005 that we had noticed the web was reinventing itself with terms such as Ajax and Web 2.0 being created to help define the new technologies and ideas. As time has gone by, snippets of those techniques are on most modern websitesfew websites require a page refresh to the server when updating information nowadays. Some sites have even harnessed the techniques in more depth and become full web applications, for example, Google Docs.
Now, in 2012, we stand at the beginning of the next reinvention, one that will further push the complexity of web applications. As we move toward the cloud, users will begin to expect web applications to be equivalent to the desktop ones theyll be replacing. As more people gain access to smartphones, tablets, and related devices, there are opportunities to harness HTML 5 to provide web applications giving the same functionality as native apps, but you only have to write once rather than per device. These applications must be more robust than ever and will need the stability, speed, and responsiveness that at least matches native applications, if theyre to be taken seriously.
To reach that point, well see a maturing from ad hoc web development that includes a sprinkling of Ajax toward the use of solid, well-tread, and proven engineering techniques that are commonly available in desktop developmentsuch as applying architectural patterns such as MVP as well as harnessing dependency injection. At the same time, the flexibility of design, so well established in the web with separation of functionality from styling, needs to be maintained and harnessed.
But there are still the same challenges in the development world that we saw seven years ago around how to effectively manage a project using JavaScriptwhere were missing the ease of development that comes with typed languages, testing, and powerful IDEs with debugging capabilities. As we said in the first edition, its possible to manage a successful JavaScript project, but the need to develop and maintain several different versions of code for differing browsers is a headache, even with the use of modern libraries such as JQuery and the like. We can add to that the additional headaches weve experienced when trying to maintain all those versions over the lifecycle of the project, especially in the maintenance phases.
It also remains, in our experience, a challenge to find enough JavaScript developers who are aware of the necessary browser issues and nuances and who are also at a sufficient comfort level with production-quality development processes to deliver a large project (compared to the number of Java programmers).
Step forward the latest versions of the Google Web Toolkit. GWT provides the support necessary for industry-grade techniquesevent busses, the model-view-presenter (MVP) pattern, together with a reference implementation that can be built on activities and places, as well as the ability to harness dependency injection through Guice/GIN.