Applet initialization problem

DOM manipulations in a web application may cause the applets in the application to reinitialize. Sometimes this can be annoying because the reinitialization causes the applet to lose its state.

I ran into this problem recently in a project when we incorporated a JavaFX widget into our DHTML/JavaScript application. I have not been able to find much information about this issue on the web and ended up doing a lot of JavaScript debugging. So in the hope of saving others some valuable time, here are the three scenarios we observed which causes the reinitialization problem:


  1. Changing the display style of an applet or a parent of the applet to any value other than "none" causes the applet to reinitialize in Firefox and Chrome. This change does not cause any problems in IE. Cross browser support was essential to us so I ended up changing the visibility or width&height attributes of the applet to hide it instead of setting its style.

  2. Reinserting an applet or a parent of the applet to any position in the DOM tree causes the applet to reinitialize in IE, Firefox, and Chrome. In IE it's reinitialized both when removing from and inserting into the DOM tree.

  3. Changing overflow style of a parent of the applet causes the applet to reinitialize. This behavior is only observable in Firefox.

It's best to avoid these three DOM operations on an applet or a DOM element which contains an applet at any depth. While there is an easy workaround for the first issue, there is no quick fix for the other two. Fortunately, I was able to fix the JavaScript code to make it all work in the end.

You can download the source code which demonstrates these issues from here.


M. Serdar Bi├žer

Comments

Popular posts from this blog

Powerful Free Webinar Network for Oracle Developers

Monitoring Oracle Database with Zabbix