« Google Maps Component for Echo2 | Main | The JavaRanch GWT in Action Review »

Review of GWT in Action

Any time a hot technology comes along -- and GWT is certainly white-hot -- publishers compete in a mad scramble to get the first books out the door. Often quality suffers. I am happy to report that GWT in Action is a strong effort that doesn't seem to suffer from this quality problem. (That isn't to say there aren't any errors and omissions in the book, just no obvious ones that I've found in my reading of it.) Instead, the book offers a solid, learn-by-example approach to understanding the Google Web Toolkit.

This learn-by-example approach, tied together through the development of a dashboard application over the course of several chapters, strikes, I think, the right balance for a broad audience. This is not the reference "bible" for GWT, though it does contain more reference material in one place than any other source so far, so you'll have to wait for that sort of reference work. But for anyone wanting to get a jump start on GWT, start developing applications, and understand what all the fuss is about, I heartily recommend this book.

The book is organized into 17 chapters, split into four parts: Getting started; Building user interfaces; Advanced techniques; Completing the understanding. So, on to what's in the book, chapter by chapter:

  1. Introduces you to the central ideas of GWT: compiling Java in JavaScript and debugging in Java. Does a good job of touching on most of the features of GWT -- widgets, internationalization, JRE emulation library, RPC, browser history, etc. -- and illustrating them with code samples. Finishes off with a complete client-side (no RPC) tic-tac-toe example app.
  2. Things slow down a bit here, as the authors delve into the organization of a GWT project and the details of the GWT development cycle. I'm torn on whether this chapter could have been illustrated more clearly with an example application, rather than just by enumerating the steps and components and diagrammatically illustrating the work-flow. The information that's here is solid and correct, but the approach seems to conflict with the learn-by-example used so well in the rest of the book.
  3. Begins the process of developing the Dashboard application -- essentially a web desktop or portal with draggable component apps. It makes concrete the more abstract development life cycle notions of the previous chapter. At the end of this chapter you have a skeleton application with menus,
    a trash icon and some basic CSS styling, and you will have run it (and debugged in Eclipse for hosted mode) in
    both hosted and web mode. This chapter attempts to instill good behavior by adding i18n ("internationalization" with the 18 letters between the "i" and the "n" omitted) at the very beginning. That way if you leave it our of your apps, you have no one to blame but yourself. You'll also have a good understanding of the major project files: the HTML file, the EntryPoint, and the module XML file.
  4. The start of Part 2 of the book which introduces GWT "widgets" -- in short, GUI components. Dissects their dual nature as Java objects and DOM elements and introduces the basic GWT widget set. Covers several common GUI and Web concepts, such as DOM events, focus, keypresses, etc. Shows two different ways of developing custom widgets -- one from scratch by manipulating the DOM and the other, the PNGImage to support transparent PNG's in IE6, by extending an existing widget class. Finishes off by building the first two custom widgets for the dashboard application, the TwoComponentMenuItem and the ToggleMenuItem. The full details of building the PNGImage class, using GWT's technique of deferred binding to handle browser differences, is split between here and Chapter 15. Small nit: I think the concept is important enough to have merited a section of its own in this chapter or the other.
  5. Presents the basic concepts of GWT panels -- the containers that hold widgets and other panels. If you know Swing, this will all seem pretty familiar, in particular DeckPanel, FlowPanel and DockPanel should seem familiar. (It is interesting to note that in GWT, layout is specified through inheritance (Is A FlowPanel), while in Swing it is a pluggable behavior (layout manager).) Of course, remember to pay no attention to the HTML Table behind the curtain, at least not if you want your code to keep working when the implementation changes. The chapter finishes off by extending DialogBox to a DashboardPanel that can be used and manipulated in a multi-window interface (or MDI).
  6. Focuses on Events, both Browser/DOM events and it's custom Widget events. This is a long chapter (over 50 pages) and covers lots of territory. If you already know your way around Java and the various kinds of Listeners, you've won a quarter of the battle, but you may want to brush up on the browser side of the equations a little bit before reading it (see here, here and here). Not that the chapter doesn't do a good job of presenting the material, but sometimes you need to have a firm grasp of one topic before combining it with another, and I think this is definitely one of those times. The chapter finishes off by implementing drag-and-drop for the Dashboard app, combining the widget knowledge from the previous two chapters with your new understanding of events.
  7. Composite widgets are again old hat if you have experience with Swing. Basically you combine existing widgets into "mega" widget. This chapter illustrates the concept by walking your through the implementation of three composite widgets: EditableLabel, ColourPicker (Colour=Color, for the Yanks in the audience), and the DashboardComposite framework class.
  8. Introduces JSNI (JavaScript Native Interface), essentially a way of fooling your IDE and the Java compiler into ignoring embedded JavaScript in your GWT code, while allowing the GWT Java to JavaScript compiler to make use of it. Demonstrates wrapping the Google Video and Ajax search libraries with JSNI.
  9. Gets into the nitty gritty of how GWT modules are put together. Essential if you are going to build reusable libraries and components that can be included in GWT applications. Really, this is where you start to find out about the inner workings of GWT, the XML, the JavaScript, etc. This chapter could stand to be a bit more in-depth. Don't skip over it in any case.
  10. The start of Part 3 of the book -- advanced techniques. Introduces GWT-RPC, i.e. the GWT abstraction over XMLHttpRequest. Make sure you have a firm grasp of XMLHttpRequest before you delve into this chapter (see here and here). Again, it helps to be well versed in the basics when something new is introduced. The chapter does a good job of explaining perhaps one of the more confusing bits of the GWT -- two execution environments (client and server), three Java classes, Sync, Async, callbacks, and the IsSerializable interface. Also show how to use the typeArgs annotation to give hints to the GWT compiler (not something you usually see in online tutorials).
  11. Digs into the client-side part of RPC. Offers patterns for simplifying the GWT-RPC code through the Facade, Singleton and Command patterns. Examines ways to implement both server pull (GWT-RPC polling) and push (blocking server threads, but see also GWT and Comet - Using GWT with Jetty Continuations). Also explains custom field serializers -- needed for some complex objects or objects that don't implement IsSerializable or have a zero argument constructor.
  12. Covers the more traditional ways of doing Browser/Server communication, with the traditional XHR style RequestBuilder, parsing the returned XML data with XMLParser, and traditional postback with FormPanel.
  13. Introduces JSON (JavaScript Object Notation) and the GWT classes that support it. It wouldn't hurt to review the basics of JSON a bit more here, but it's not quite as important as in chapters 6 and 10. Demonstrates its application through use of the Yahoo Search API. Shows how to use JSON to integrate with Java, Perl and Ruby on the server. The latter examples are fairly simple, but they give you enough to start rolling your own. (FYI, you can also do JSONP with GWT.)
  14. GWT generators are a compile-time mechanism for generating new classes based on parameters (used from JUnit, logging, RPC, etc.). Builds on the module knowledge from chapter 9. This chapter gets deep into the inner workings of the compiler. As it turns out, you can do introspection in GWT, but only at compile time.
  15. Gets into various runtime and compile-time parameterization of GWT apps, specifically i18n, constants, dynamic constants (client side associative arrays) and browser specific code. This is where you have to go to understand exactly what you did with the PNGImage class.
  16. The start of Part 4 of the book. Covers a number of topics: JUnit and GWT, testing async code and deploying GWT apps on the client and server sides. The JUnit and async testing piece really should be a chapter on its own. The section on deploying GWT apps points out many of the hidden pitfalls packaging up an app, such as the old or unused files generated during development that need to be removed for a slim package.
  17. This chapter is the natural continuation of chapters 9 and 14. It delves even deeper into the inner workings of GWT, such as the compilation process and the generated and static JavaScript files that make up an application. It also gives a quick tutorial on how to diagnose problems on the client side using the PRETTY and DETAILED styles of JavaScript output.

The book does cover many of the new features in GWT 1.4, such as Image Bundling, the new loading mechanism, and the Serializable vs IsSerializable changes. Some of the new widgets, such as the Rich Text Editor, are not covered, however.

As I've said, overall a fine effort. I do have three issues with the book, however. First, there is no mention of the incompatibility between GWT and IE7. Since much of the world's population still uses IE7, that's a major oversight. It would have been nice to at least mention the hack to UserAgent.gwt.xml to make it work for IE7. The other issue is that the rich UI sample Dashboard application really deserved a transactional companion, i.e. some sort of app that illustrates how GWT would function with a more substantial server-side app. That may be a little too much to ask of one book that tries to introduce so many new concepts and ideas already, and there are some online tutorials that provide just that sort of example.

the Finally, testing with JUnit is relegated to the penultimate chapter of the book. Software development is momentum and habit. If you start off developing without unit tests, you will have a hard time incorporating it into your process later on. Testing should have been presented in the first chapter and used throughout in each subsequent chapter, so as to givereader a good grounding in JUnit and GWT.

Still, the three issues certainly don't detract enough from the book to change my overall opinion: definitely read this book.

Technorati Tags: , ,

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/776034/20256270

Listed below are links to weblogs that reference Review of GWT in Action:

Comments

Post a comment

If you have a TypeKey or TypePad account, please Sign In

Contact Us
ajax@pathf.com

Pathfinder Development Careers

Search


AgileAjax RSS Feed

AgileAjax Email Feed

  • email feed

    Enter your email address:

    Delivered by FeedBurner

Categories