Oops Null Pointer

Java programming related

Category Archives: GWT

Book review: ExtGWT Rich Internet Application Cookbook

ExtGWT cookbook

Overview:

The ExtGWT Cookbook from Packt Publishing covers the GXT UI framework version 2 (currently at 2.2.6) as well as a quick overview of key features of GWT and some ideas on building robust UI frameworks. While a good knowledge of GWT itself is recommended, this book could be used a basic primer of some of the required concepts.

I think it’s important to bring up that the version of GXT this book covers is now a major revision behind the latest: GXT 3.0.

A lot has changed in GXT 3.0 and thus some of the detail in the Cookbook is not applicable to projects using this version. Some examples are:

  • The GXT data model (BeanModel) is now replaced by POJOs (using GWT AutoBeans)
  • Wigets can now use UIBinder
  • GXT Event listeners are replaced by GWT handlers
  • The flash charts are replaced by a new JavaScript based chart package

So with that in mind, who is this book useful for? The GXT widgets are relatively unchanged and this book covers the set-up and options of nearly all the widgets in detail and is still helpful from this aspect. The book also covers some useful ideas for building robust UI frameworks; it explores the idea of an “action” that different views can share, each which their own set of supported options. For those who have existing investments in applications using GXT 2 or are just starting projects will find this book a great companion – I wish I had this book during the creation of my current application as it would of helped clarify some of the quirks in GXT and replace the rather lack lustre GXT documentation. It also would of added some depth in the architecture, reducing repetition and linking related components.

Layout:

The ExtGWT Cookbook’s layout is code heavy – in a good way. Each recipe follows the format of a description of a feature, a “how do do it” code section and a detailed “how it works” line by line breakdown of the code. In this way you are rarely left wondering what a line of code does and any GXT quirks are normally highlighted and explained.

The progression of the examples builds well through each chapter and in the same way the chapters tend to naturally flow on from one another, so the book can be read linearly, but each chapter is self contained enough that you can jump into a recipe with little reference to other sections.

The main documentation that GXT provides is the API and a set of examples with code. While better than nothing, they often are not enough to cover real life scenarios or they leave important options out. The ExtGWT Cookbook has more examples with a focus on building practical applications, and importantly the examples are detailed and backed by a comprehensive description.

I felt the detail and relevance was typically compelling enough to encourage reading through whole chapters. Nearly ever chapter covered a new aspect or feature that I hadn’t previously been aware of, making reading this book worthwhile.

Chapters:

The first three chapters cover the basic elements of panels, windows, tabs and “click-ware” (buttons, toolbars and menus). The section on tabs shows real world experience in the example which toggles the tab strip based on the number of tabs. The last recipe of chatper 3 “Bind a single action to several click-wares” introduces a useful pattern to relate an underlying action or behaviour to different representations that is elaborated and expanded in Chapter 11 in the recipe “A novel UI with MVP, actions and a bus”.

The next four chapters cover GXT specific layouts, trees and grids with enough thoroughness to provide a good head start in using these components.

Chapter 8 covers the GXT templates which allow the modification of views within components with easy access to model data properties. This was a topic that I found GXT’s own documentation was particularly unhelpful, while this chapter succinctly covered with several handy examples.

The built in charts are well covered in Chapter 9, although few would find this flash based package very useful (especially for mobile devices). The last recipe “Drawing on a canvas” hints at alternatives, but for detailed charts look to GXT 3 or an external library.

The chapters “Drag-and-drop”  (chapter 10) and “Theming” (chapter 12) adequately explain these topics and the appendices provide thoughtful coverage of topics that GWT developers need to know.

I found the “Advanced Tips” chapter (11) the most useful and insightful as it covered important architectural concepts for larger applications (MVP, History, working with persistence frameworks). Having gone through the pain of building similar patterns before they were more commonly discussed for GWT projects, I like the way this chapter helps lay the foundations of testable and robust GWT based software. The working server push recipe was also stimulates thoughts on building more interactive applications.

Summary:

In all the ExtGWT Cookbook is a very detailed and comprehensive overview of GXT 2.x. It inspired me to read the whole thing cover to cover and I only really didn’t learn something from the charts chapter as we have moved to Highcharts (and GXT has moved to a new JavaScript based charting framework in GXT 3).

There are some aspects of GXT’s layout system that were (for me) difficult to deal with that are not covered in this book – in particular deeply nested layouts and using components in resizable windows (say a grid in a portlet in a resizeable window). The GXT documentation avoided complicated layouts and the cookbook’s layouts are typically not too complicated either. This book is aimed at the beginner to intermediate as it lacks some depth in relation to constructing large / complicated GXT based applications, but it still has enough detail to learn some useful tips from.

I’d look forward to a GXT 3 version by the same authors, especially if it covered some more advanced patterns.

Advertisements

ExtGWT Cookbook Review in progress

I’m in the process of reviewing a GXT book called ExtGWT Rich Internet Application Cookbook.

Hopefully I’ll pick up a few tips on the way. It will be interesting to compare it to a book a did a technical review for around a year ago: Ext GWT 2.0 Beginners Guide.

Upgrade GWT 2.0.4 to GWT 2.4.0 with GXT 2.2.5

I just upgraded from GWT 2.0.4 to GWT to 2.4.0 and here are the jars I had to change:

Run time dependencies (WEB_INF/lib):

  • updated gwt-servlet.jar to 2.4.0 version
  • updated GXT.jar (2.2.5) had to be a version compiled for GWT 2.2 and above (previous I used the 2 version)
  • updated gwt-log-26.2 to gwt-log-3.1.6.jar
  • updated guice-2.0.jar to guice-3.0.jar
  • added guice-assistedinject-3.0.jar
  • removed gwt-java-math-1.0.9.jar (andremoved the reference from the module (gwt.xml) file
Build time dependencies:
  • updated all the GWT jars
  • updated gin-1.0.jar to gin-1.5.jar (post GWT 2.2 version)
  • added javax.inject.jar that comes with guice-3.0 (new)

GXT: BorderLayout starting with a collapsed region

Calling collapse on a BorderLayout region before it has been rendered doesn’t work. One suggestion was to add a deferred command to collapse the region. I found this was “flashing” the panel (showing and then hiding it) and also that when you pop out a collapsed panel (clicking on the collapsed section) the popup was empty as panel was still effectively collapsed. Instead I used a once only AfterLayout event listener:

layoutContainer.addListener(Events.AfterLayout, new Listener<ComponentEvent>() {
  public void handleEvent(ComponentEvent be) {
    borderLayout.collapse(LayoutRegion.WEST);
    be.getComponent().removeListener(Events.AfterLayout, this);
  }
});

Using this method some child components may have trouble rendering inside the collapsed panel. One such component is a TreePanel – if you add it and then call expandAll() it will throw a JavaScriptException, caused by the parent of the collapsed panel being null.
com.google.gwt.core.client.JavaScriptException: (TypeError): this.appendChild is not a function

To counter this I added a once only Attach event listener to the panel that will be collapsed:

myContentPanel.addListener(Events.Attach, new Listener<ComponentEvent>() {
  public void handleEvent(ComponentEvent ce) {
    myTreePanel.expandAll();
    // Remove this listener - expand only once
    ce.getComponent().removeListener(Events.Attach, this);
  }
});

Determining GWT Version from jar sizes

I ran into a few cases trying to build a GWT project that does not clearly state which GWT version it uses. AFAICT the gwt-servlet.jar doesn’t give any clues in the manifest or else where.

Here’s a list of versions of gwt-servlet.jar and file sizes (KB):

  • 2.0.0 – 1,524 KB
  • 2.0.1 – 1,535 KB
  • 2.0.2 – 1,538 KB* see below – 1,574,024 Kb,
  • 2.0.3 – 1,558 KB* see above – 1,574,034 Kb
  • 2.0.4 – 1,538 KB
  • 2.1.0 – 2,776 KB
  • 2.1.1 – 2,906 KB
  • 2.2.0 – 4,280 KB
  • 2.3.0 – 4,889 KB

Prior to 2.0.0 there is a separate version for Win/Mac/Linux

Got any others to add?