views:

39

answers:

1

I am looking to compile my gwt application into a single, monolithic, cross-browser compatible .html file. Ultimately, I'm trying to design an Amazon mechanical turk template via gwt. These templates must be a single .html file, since they are hosted on Amazon's machines. The .html file can reference external sources, but via absolute address only since I have no control over the file hierarchy.

It does not concern me that the monolithic file will load slower than having separate files for each browser. I am developing a fairly simple web form containing only client-side code that will be seen by very few people. Therefore, speed and cross-browser correctness are not primary concerns.

I have found that by adding the following line to my MODULE_NAME.gwt.xml I can generate a single javascript file that works exclusively for a single browser (e.g. firefox as shown below):

<set-property name="user.agent" value="gecko">

I then embed the generated code into my .html file, and it works for the single browser specified. Unfortunately, when I try opening the .html file in other browsers, the gwt generated javascript does not load.

Is there a linker command that I can add to this file that will do the trick? I tried to invoke the SingleScriptLinker via:

  <add-linker name="sso" />

but got the following error:

[ERROR] The module must have exactly one distinct permutation when using the Single Script Linker.

I also attempted to tweak the contents of the generated javascript files in order to make them compatible enough to embed in the .html file, but the javascript generated by gwt is too confusing (even in the detailed output mode). Is there a walk-through for how to do this?

I'm using the gwt eclipse plugin on OSX.

A: 

As luck would have it, I have found a workaround soon after posting my question: http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/79e9634110487490

In short, the answer is to use cross-site scripting.

  • Add the following line to MODULE_NAME.gwt.xml:

    < add-linker name="xs" />

gwt will generate a MODULE_NAME.nocache.js file as well as some MD5.cache.js files (note the MD5 files end with .js, not .html).

  • Compile your application

  • Now, put all of these .js files on server A.

  • Modify your MODULE_NAME.html file to contain an absolute reference to MODULE_NAME.nocache.js on server A.

  • Upload MODULE_NAME.html to server B.

The cross-site linker makes everything work.

dsg