views:

364

answers:

2

We are looking at integrating a full-blown GWT (Google Web Toolkit 2.0) application with an existing ASP.NET 3.5 application. My first gut reaction is that this is a horrible frankenstein idea. However, the customer has insisted that we use this application developed by a third-party.

I have almost NO CONTROL over the development of the GWT app.

My first thought is to actually attempt to embed this in an iFrame. Because GWT is running under Tomcat/Jakarta, it is hosted on a different server from the .NET app so the iFrame src will be to a URL on the other machine.

I need to utilize our own ASP.NET authorization scheme to restrict access to the embedded GWT application. The GWT app also uses embedded java applets, which don't seem to be working right now inside the iframe. The GWT app makes calls to a backend server (using GWT-RPC?).

Any major problems with this approach that anyone can see? Will GWT work on an iframe while hosted on a different machine?

NOTE: SIMPLY ADDING A DIV WITH THE SAME NAME DOES NOT WORK FOR THIS!

A: 

you do not need an IFRAME. Writeyour application so that the main panel is hosted inside a div with a specific id. If your ASP.net can provide a div with the same id, then all you have to do is include the generated JavaScript files (+ some style sheets) and your application will display inside the div.

Tony BenBrahim
+1  A: 

To expound on what Tony said, GWT can live on any page. At its lowest level, GWT hooks into a div by its ID or the body element, as its RootPanel, and adds widgets to it from there.

Simply add a div to your ASP page like <div id="gwt-root" /> and in your GWT code, start with RootPanel root = RootPanel.get("gwt-root"). Then you can start adding widgets to that panel to build the GWT portion of your page.

You'll also need to bring in your GWT generated code with a script tag, like so:

<script type="text/javascript" src="gwt-app-name/gwt-app-name.nocache.js">

Also, if you want, GWT can interact with the rest of the page using regular JavaScript using JSNI.

Jason Hall
Please note in the original question. I don't have access to the original GWT source and it is being hosted on a different machine so doing what your suggesting would actually be a XSS problem right? Since I can't reference the *.nocache.js file on a different server.
Jay Stevens
You can reference a JS file from any site (as long as the file is readable). Simply change your `script` tag to an absolute URL to `http://otherserver.com/gwt-app-name/gwt-app-name.nocache.js`. Where you might have problems is in making GWT-RPC requests... in that case, you can do just as you say and run the GWT app inside an iframe hosted on the other server.
Jason Hall