TSSJS2010: GWT fu: Going Places with Google Web Toolkit

This session provides an introduction to the GWT for designing web clients.

With GWT 2.0, the Hosted mode browser plugin allows you to run in the various browser directly.

It’s probably due to limitations from my hangover, but apparently we’re running Javascript on the client but it looks like we’re writing Java.  Is GWT somehow converting my Java into Javascript?  I think that Geary alluded to that fact, but I’m not quite sure.  The code for ClickHandler certainly looks like Java though.   As a matter of fact, I later got confirmation that this is indeed the case.   With GWT, you write Java and GWT takes care of generating the Javascript!  So sweet!!

Hosted mode browser plugin – running in the various browsers directly
Code splitting is a useful pattern to use.  Because GWT applications are downloaded to the client as Javascript, they can get pretty big pretty fast.  Code splitting lets you split out your code and lazy download as needed.

Layout panels provide an easy way to create layouts without too much fuss a la Swing.

Client bundles lets you pull down a bundle of resources in one http request

WebAppCreator application is used to generate the web application:

webAppCreator com.clarity.SimpleApp

GWT now creates a bunch of stuff for us.

ant hosted

Import project into Eclipse.   Nice to know it integrates seamlessly with Eclipse, by the way.  😉

All GWT Applications are modules.  From the code, it looks like the server implements a Remote interface.   Also it would seem that GWT allows you to plug into Hibernate.  It isn’t just a Web framework, then?

Event Handlers

Event Handlers are very similar to Swing/AWT/SWT listeners.   They’re typically implemented in anonymous inner classes.

Swing came with adapter classes for event handling with no-ops.   GWT first came out with the same paradigm.   Not all GWT widgets are notified about all events.   You can sync events on a widget to be notified of events you typically wouldn’t receive.

History

GWT has a history mechanism as well.  It’s apparently very slick and it handles something of a state, but I’m not quite understaning why it’s so slick.   Then again, I was at the Blackjack table until 2:30 AM drinking free Gin and Tonics, so my mental capacity is somewhat muted.

Go, Speed Tracer, Go!

Speed Tracer monitors any web application and gives all kinds of data as to how many requests are being made, how long it takes, etc.  In short, it’s a GWT supplied performance analysis app and it’s good to use to improve the performance of your web app.

Code Splitting

Code Splitting is achieved by surrounding the code you don’t need right away inside a GWT.runAsync() block.   That allows for lazy-loading of code that’s not needed right away.

Best Practices

  • Use History from outset
  • Design for UIBinder from the outset
  • Consider MVP and on event bus
  • Use Speed Tracer and code splitting for performance

GWT, in many respects, is like Swing.  It allows you to build your web page GUI using a very Swing-like API.  No Javascript, No Ajax.  Just pure 100% Java goodness!