Building Wave Gadgets with GWT

Thursday, July 15, 2010 | 8:24 PM

Labels:

Hilbrand Bouwkamp is an independent internet developer/trainer/presenter specialized in RIA, GWT and Android. He has been following GWT and Wave since it's first release and has created two open source libraries related to GWT and Wave: cobogw and cobogwave.This blogpost is about the cobogwave library.

As soon as Google Wave was released and I had an account, I wanted to write a Wave Gadget. I believe Gadgets are one of the strengths of Wave because they let you add a structured component to an unstructured communication flow to make things more efficient. For example, a simple date picker Gadget can be added to an event-planning wave, and instead of people having to go to a separate site and communicate their date preferences manually, they can do the date-selection in the wave, and all of the information is stored in a single place. There are many situations like this where gadgets can add structure and keep related information together.

Since the Google Wave client itself is build with GWT (Google Web Toolkit), I thought it to be natural to write a Gadget with GWT. To do that, I needed to wrap the Wave Gadgets JavaScript API with my own GWT JSNI wrapper. Like other GWT gadget developers, I wrote my own wrapper - but I wanted to do it in a way that other developers could benefit from. So, I made sure that my wrapper included all of the Wave Gadgets API functionality, I wrote documentation for it, and I open-sourced it under the Apache 2 license as the cobogwave library. Now, other developers can skip the wrapper-writing step and simply focus on writing their gadget.

The cobogwave library makes it very easy to build gadgets for Wave. Just like the iGoogle GWT Gadgets API library, it defines a Needs interface: NeedsWave. By implementing the interface, you can make your gadget code Wave-enabled. Or, you can simply extend the WaveGadget class for the same effect.

GWT developers are accustomed to work with handlers, so the cobogwave library provides much of its functionality via handlers. For example, you can register for the ModeChangeEvent to be notified when the user changes from playback to edit mode, ParticipantUpdateEvent when a new user is added or removed to the wave, and StateUpdateEvent when the gadget receives a new state. The cobogwave library also has support for experimental functionallity in the Wave Gadget library, like the Wave UI Widgets Button, Frame and Dialog.

Recently, I was involved in the latest release of the gadgets support in the Google API Libraries for GWT. In the new version, it's much easier to implement RPC calls to your own server, and this method also works for Wave Gadgets.

Here's a sampling of diverse range of gadgets that developers have built using the cobogwave library:

  • Shortyz: Lets you solve crosswords together in a wave - ported from Android code.
  • MindMap: Lets you create an interactive mindmap, and favorite nodes up or down.
  • Karma: Lets participants in a Wave rate each other.
  • Pongy: Lets you play the classic game "Pong" with a fellow Wave user. (This last gadget was written by me to showcase the highly interactive possibilities of Wave.)

To start building your own Wave Gadgets with GWT, visit the cobogwave project page and to keep informed on updates, follow me on Twitter.