All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Published by Packt Publishing Ltd.
Birmingham, B27 6PA, UK.
Credits
Author
Prabhakar Chaganti
Reviewers
Luca Masini
Travis S. Schmidt
Development Editor
David Barnes
Assistant Development Editor
Nikhil Bangera
Technical Editors
Rashmi Phadnis
Ved Prakash Jha
Editorial Manager
Dipali Chittar
Project Manager
Patricia Weir
Project Coordinator
Suneet Amrute
Indexer
Bhushan Pangaonkar
Proofreader
Chris Smith
Layouts and Illustrations
Shantanu Zagade
Cover Designer
Shantanu Zagade
About the Author
Prabhakar Chaganti is an enterprise software architect and open-source evangelist working for a cutting-edge software company in the suburbs of Atlanta. His interests include Linux, Ruby, Python, Java, and Virtualization. He recently won the community choice award for the most innovative virtual appliance in the 2006 VMWthis award is the Ultimate Global Virtual Appliance Challenge.
This book has gained immense support from various people. The staff at Packt Publishing were very helpful in providing key assistance to me and ably and enthusiastically led me through the various phases of this project. I would like to thank the technical reviewers for their comments, which have helped make this a much better book. The vibrant community around the GWT mailing list was very helpful whenever I needed clarifications on some of the more arcane corners of GWT.
I would like to thank my wife Nitika for her support and constant encouragement while I was writing this book. She effortlessly played the roles of both mom and dad while I was wrestling with GWT! Thanks and love to my two daughters Anika and Anya for putting up with daddy being stuck to his laptop for long periods of time instead of playing with them.
About the Reviewers
Luca Masini was born in Florence in 1971. He is a senior software engineer and web architect. He has been heavily involved from the first days in the Java world as a consultant for the major Italian banks and firms, developing integration software, and as technical leader in many of the flagship projects. He worked for adoption of Sun's J2EE standard in an envinroment where COBOL was the leading language, and then he shifted his eyes toward open source, in particular IoC containers, ORM tools, and UI frameworks. As such he adopted early products like Spring, Hibernate, and Struts, giving customers a technlogical advantage. During last year he fell in love with GWT (of course !!) and he had to master a new project all done with Oracle's ADF Faces and JDeveloper as Visual IDE.
I want to thank my son Jacopo for being my lovely son and my wife for being the best wife a man can dream.
Travis S. Schmidt (BS, MBA) is currently employed as an Applications Developer at the University of Iowa Hygienic Laboratory. He has several years of experience in designing and developing web-based clients and recently deployed a system utilizing the Google Web Toolkit.
would like to thank my loving family: Rebecca, Jacqueline, and Alexander, for the their unwavering support.
Preface
The client-server architecture has undergone a vast change over a short period of time. Earlier, each application had a different client software, with the software serving as the UI. This software had to be installed individually on every client, and needed to be updated every time we made changes to the application. We moved from that to the web era and deploying applications on the Internet, and then Internet enabled us to use the omnipresent web browser for accessing our applications from anywhere. This was a sea change, but we still had issues of performance and applications not having the same feel or responsiveness as desktop applications. Enter AJAX, and now we can build web pages that can rival a desktop application in responsiveness and nifty looks. AJAX underpins the current trend in developing applications for the Internet known as Web 2.0. In order to build Ajaxified applications you need to know HTML, XML, and JavaScript at the very least.
The Google Web Toolkit (GWT) makes it even easier to design an AJAX application using just the Java programming language. It is an open-source Java development framework and its best feature is that we don't have to worry too much about incompatibilities between web browsers and platforms. In GWT, we write the code in Java and then GWT converts it into browser-compliant JavaScript and HTML. This helps a lot, because we can stop worrying about modular programming. It provides a programming framework that is similar to that used by developers building Java applications using one of the GUI toolkits such as Swing, AWT, or SWT. GWT provides all the common user-interface widgets, listeners to react to events happening in the widgets, and ways to combine them into more complex widgets to do things that the GWT team may never have envisioned! Moreover, it makes reusing chunks of program easy. This greatly reduces the number of different technologies that you will need to master. If you know Java, then you can use your favorite IDE (we use Eclipse in this book) to write and debug an AJAX GWT application in Java. Yes, that means you can actually put breakpoints in your code and debug seamlessly from the client side to the server side. You can deploy your applications in any servlet container, create and run unit tests, and essentially develop GWT applications like any Java application. So start reading this book, fire up Eclipse, and enter the wonderful world of AJAX and GWT programming!
In this book, we will start with downloading and installing GWT and walk through the creation, testing, debugging, and deployment of GWT applications. We will be creating a lot of highly interactive and fun user interfaces. We will also customize widgets and use JSNI to integrate GWT with other libraries such as Rico and Moo.fx. We will also learn to create our own custom widgets, and create a calendar and a weather widget. We will explore the I18N and XML support in GWT, create unit tests, and finally learn how to deploy GWT applications to a servlet container such as Tomcat. This book uses a typical task-based pattern, where we first show how to implement a task and then explain its working.