Calling the JOGLAppletLauncher subapplet from JavaScript

Hi,

I was wondering if it is possible to call methods on the JOGLAppletLauncher subapplet (the “real” applet) from JavaScript. As I understand it, you can only call methods publicly exposed by the applet from JavaScript. Since the applet happens to be JOGLAppletLauncher, there seems no way for me to invoke methods on MY applet that is being started by JOGLAppletLauncher. Is there something I’m missing?

If there is currently no way to do this, I think a reasonable way to allow this behavior (though I haven’t tried it yet) would be to add a “getSubApplet” method to JOGLAppletLauncher.

If adding a getSubApplet method would allow this to work, there’s no problem in adding it. Could you please prototype it though and see whether it enables what you want to do?

I made a copy of the JOGLAppletLauncher class and added a public getSubApplet method:


 public Applet getSubApplet() {
    return subApplet;
  }

This change did the trick and I was then able to call methods on my applet from JavaScript like this:


document.appletlauncher.getSubApplet().callMyAppletMethod();

So, yes, please add the getter to JOGLAppletLauncher.

As an aside, I tried getting around having to change JOGLAppletLauncher by noting that JOGLAppletLauncher isa Container with the sub-applet as its only child. The following JavaScript worked in Firefox:


document.appletlauncher.getComponents()[0].callMyAppletMethod();

but it did not work on IE, giving me an error along the lines of “document.appletlauncher.getComponents().0 is null or not an object”. Anyone with more JS foo than I have any idea why this wouldn’t work in IE?

Thanks for verifying this. The getter has been added.

I have no idea but did you try calling getComponent(0) instead of getComponents()[0]?