gwtXPDownloadsBlog

Using OOPHM to develop XUL applications

Posted in GWT on October 30th, 2009 4 Comments

GWT bootstrap script

This post shows how we can use OOPHM to develop XUL applications in GWT. In this post, we will develop a Firefox extension and you can try yourself on Thunderbird and XulRunner.

In previous versions, GWT uses Hosted Browser and it is the only the supported browser during development cycles.

With new version, GWT 2.0 milestone 2, developers are free to choose their favorite browser, and they can develop applications from multiple browsers with OOPHM – Out Of Process Hosted Mode.

GWT has several linkers which generate the bootstrap scripts for your application.

The default IFrameLinker’s script uses document.write to inject other required scripts. However, because document.write is not available in XUL, the normal GWT bootstrap process does not work for XUL.

In addition, this bootstraps script creates a iframe element to load other scripts. Because for security reasons, content in this iframe can not access its parent chrome. See https://developer.mozilla.org/en/XUL/iframe.

XulLinker

Thus, we created another specific linker XulLinker for XUL applications. XulLinker uses Mozilla’s specific function document.loadOverlay to securely load the other scripts. XulLinker is test to run on Windows and Linux. Its source code is included in the download file.

For the purpose of this demonstration, we write a Hello application. The screenshots is as below:

Test XulLinker
Normal xul application e.g unprivileged mode

Test XulLinker In Chrome Mode
Chrome mode e.g privileged mode

GWT Development Mode
GWT-Development-Mode

The example is simple, and you can discover its source code yourself. However, some key points you need to know:

  1. In TestXulLink.gwt.xml we added a new linker: <add-linker name=”xul” />
  2. The .xul file and .nocache.js must be in same directory
  3. You have to create a Firefox extension stub and install it before writing GWT code. For this example, copy file xullinker@gdevelop.com to your Firefox extension directory and edit it to point to the war directory of this example.

Run the example in Development Mode and then type chrome://xullinker/content/XulLinker.xul?gwt.hosted=localhost:9997 in Firefox’s address bar

After compiling the example, you can run in Web mode using chrome://xullinker/content/XulLinker.xul instead.

Summary

We use XulLinker to load required scripts for GWT application. XulLinker help us to develop Firefox, Thunderbird extensions and XUL applications using Java and GWT.

Source Code: XulLinker.tgz
See the LICENSE.txt in the download file for license details.

Share and Enjoy:

  • Google Bookmarks
  • Twitter
  • Facebook
  • Digg
  • Technorati
  • Live
  • DZone
  • Reddit
  • del.icio.us
  • Mixx
  • Netvibes
  • StumbleUpon
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • email
Leave a Comment »


Recent Comments:

  • Colin: @Piotr Szaranski: I had the same issue with authentication, and I also was looking for...
  • Ora Finona: This is a bit off discussion, which I apologize for, but would you and your readers...
  • Amos: First, thanks for some great software. This is great to have. Here are collection of notes...
  • Peter Frankmann: Hallo zusammen, Sehr gute Beiträge. Danke dafür. Werde wohl noch öfters mal...
  • Trung: SyncProxy depends in gdata java client, thus download it from code.google.com Hope this...