Wednesday, May 14, 2008

Dragging Altio applets out of the browser

After experimenting with dragging simple applets out of the browser I tried to add the same functionality to Altio applets. This turned out to be trickier than I anticipated, mainly because AltioLive generates the APPLET tags in the HTML dynamically, setting lots of parameter values, dynamically selecting which Altio JAR and custom control JARs should be included.

I thought that I could just keep static values in the JNLP file and maintain the dynamic values in the APPLET tag, and this does work for dragging the applet out of the browser, however if you then close the browser then as far as I can tell your applet is 'magically' transformed into a Webstart application, which makes sense. This means that upon closing the browser Java will throw away your APPLET tag and rely solely on your JNLP file to support your applet, and will reinitialize your application based on that JNLP file, so if it doesn't contain all of the information necessary to your applet it will fail when Webstart takes over.

So, it looks like we are going to have to have dynamic JNLP files for AltioLive. The easiest way I can see to do this is to use JSP file that takes in a load of parameters, which are then used to fill in the JNLP and return it. We can embed a link to this JSP file, including all parameters, when we create the APPLET tag, and I have a little proof of concept of this up and running, as you can see from the screenshot below:

Unfortunately, there is another issue when closing the browser window: sessions. AltioLive relies on sessions when communicating with the server, and when the browser is closed we lose our session. I'm not sure what to do about this yet - whether we have to cope with that and re-establish a session or if we can maintain the session when switching from Applet -> Webstart.

No comments: