The calling page looks like this:
<html><head>
<script type="text/javascript">
function myInit() {
window.GLOBAL_config="...";
document.getElementById("myIFrame").src="x.y.gwt.App/App.html";
}
</script
</head>
<body onload="myInit()">
(generated content such as menu etc)<br>
<iframe id="myIFrame"></iframe>
</body</html>
- - -
The x.y.gwt.App folder is here copied directly from the www output
folder of the GWT compiler. Inside is the App.html which is the HTML
file generated by applicationCreator. It must be modified somewhat,
inserting javascript to access the GLOBAL_config of the parent window,
if found:
<html><head>
<meta name='gwt:module' content=x.y.gwt.App>
</head><body>
<script type="text/javascript">
window.GLOBAL_config="...default value for testing...";
if (window.parent != window) {
window.GLOBAL_config=window.parent.GLOBAL_config;
}
</script>
<script language='javascript' src='gwt.js'></script>
<div id="ROOT"></div>
</body></html>
The application reads the window.GLOBAL_config variable like this:
private native String nativeGetConfig() /*-{
return $wnd.GLOBAL_config
}-*/;
That's it.
Our case is that we will want to use GWT to develop an app that runs
inside various pages, doing different functions in each page, and
leaving the menu system to the existing web app framework. We use a
JSON string in the GLOBAL_config variable, and it will have to contain
a logical name for the page we are in, telling the GWT app which
functionality to run. This way, extending several pages of our
application with Ajax and javascript only results in one GWT
application, which is very space efficient, as new pages will
contribute only few kilobytes to resulting code.
I have tested this approach, with the parent window, the iframe, the
extra javascript and the native method, and it works on all three
browsers: IE, Opera and Firefox (after someone pointed out the
difference of upper and lower case to me!!)
:-)