I’ve been experimenting with GWT, seeing how it can be hacked into unusual applications — bookmarklets, Greasemonkey, widgets — without breaking. The answer is that there are a number of things about the GWT runtime that break in these scenarios (Each bit of code loads in a different HTML file, so each has its own sandbox, therefore, no cross site action). I’m still looking at ways to make it work, but in the meantime, GWT can be used without any problems to develop Opera widgets.
These widgets, once installed, sit on your desktop, have access to some permanent storage, and can access pretty much any site, so those cross domain Ajax doohickies you wanted to develop? Now there is a way of doing it that doesn’t involve proxying through a web server.
I took a crack at developing a little “Hello World!” app, called AnswerWidget. It allows you to enter a search term and then cycles through all of the Yahoo! Answers entries that match that term (up to 50). It refreshes and starts recycling after that.
Now besides discovering that most of the Yahoo! Answers content isn’t very good, I also found that writing a widget with GWT couldn’t be simpler. Develop your app as you normally would (you may need to drop in a test object that generates content instead of trying to do a cross site JSON request). Once you’ve compiled into Javascript, just copy your app’s html file to index.html and create a config.xml in the base dir that looks something like this:
<?xml version="1.0" encoding="utf-8"?> <widget> <widgetname>AnswerWidget</widgetname> <description> GWT widget for getting Yahoo! answers. </description> <width>495</width> <height>440</height> <author> <name>Dietrich Kappe</name> <link>labs.pathf.com</link> <organization>Pathfinder Associates, LLC</organization> </author> <id> <host>labs.pathf.com</host> <name>AnswerWidget</name> <revised>2007-01</revised> </id> </widget>
Zip it up in a zip file (what else?) so that the index.html and config.xml files are in the base dir, then upload it to your favorite server. If you’re using apache, you can create a .htaccess file in the dir where the zip file sits and add the following line:
AddType application/x-opera-widgets .zip
When you download this zip file with Opera, you will be prompted to install it. There is more on deploying Opera widgets here. I wasn’t able to get the wdgt extension to work for me, BTW.
If you have Opera installed and feel in a trusting mood, you can install the widget here. Keep in mind that if I was a malicious person, I could mount all sorts of trojan horse attacks inside your firewall. That’s one of the downsides to the GWT-based Opera Widget: without the Java source code, you will have a hard time inspecting and validating that the widget isn’t malicious.
I do hope the guys at Google work on making the GWT runtime a little bit more flexible. I have some ideas on how to hack it to make it work cross site, but that won’t be maintainable in the long run.


I realise this was a while ago, but I’m looking at this now as well — did you ever manage to get GWT-RPC to work with a widget…? Seems like it only specifies a relative path and so doesn’t work?