I just found out this article , "Accessing PHP pages in Hosted Mode
GWT", at
http://www.drivenbycuriosity.com/mywp/?p=52 and it provides
a nice solution for AJAX calls (for example, to PHP services) when in
hosted mode.
The idea is to change the default policy of the hosted browser, so it
won't protest about different origin calls. You just need to add a few
lines to the ./mozilla-1.7.12/greprefs/all.js in the GWT directory:
pref("capability.policy.default.XMLHttpRequest.abort", "allAccess");
pref("capability.policy.default.XMLHttpRequest.getAllResponseHeaders","allAccess");
pref("capability.policy.default.XMLHttpRequest.getResponseHeader","allAccess");
pref("capability.policy.default.XMLHttpRequest.open", "allAccess");
pref("capability.policy.default.XMLHttpRequest.send", "allAccess");
pref("capability.policy.default.XMLHttpRequest.setRequestHeader","allAccess");
pref("capability.policy.default.XMLHttpRequest.onreadystatechange","allAccess");
pref("capability.policy.default.XMLHttpRequest.readyState",
"allAccess");
pref("capability.policy.default.XMLHttpRequest.responseText","allAccess");
pref("capability.policy.default.XMLHttpRequest.responseXML","allAccess");
pref("capability.policy.default.XMLHttpRequest.status", "allAccess");
pref("capability.policy.default.XMLHttpRequest.statusText",
"allAccess");
The author mentions two problems: having to use absolute URLs in your
code (not a big deal for me, at least), and having to redo this
addition whenever you update to a new version of GWT (not so often, so
no big deal either).
I can add another problem. Before this change, you could write code
that would run in compiled mode, but fail in hosted mode. After this
change, you can write code that runs in hosted mode, but fails in
compiled mode... careful!
I had been trying with proxies, server configurations, Apache tricks,
and what-have-you, but this is by far the simplest possible fix.
A great solution, IMO !!
I could add that now you could write code that would