Java Applet re-creation problem
Hi skilled,
At our project we use an Applet that resides in the iFrame. On the main page the iFrame is used to show an Applet.
There is a table with two cells, there is DIV in every cell with IDs div1 and div2 accordingly. The iFrame is in the "div1".
When we move an iFrame from div1 to div2 using the JavaScript code below:
div2.appendChild(
document.getElementById('myframe')
);
where myframe is the iFrame ID, the Applet destroys and new one is being created. This leads to the loss of data that was stored in the applet before.
We need to avoid such a behavior of the Applet somehow or find a workaround to this problem.
This problem reproduces on SUN JVM 1.5.0.11 and 1.6.0.x.
Please share your ideas/suggestions with me you will help us a lot.
# 1
I can save the data from the old applet when it is going to destroy, however I cannot pass it to the new one.
Here is the problem:
- until the <iframe/> is moved, my browser has a right reference to the applet - I can use any public methods of an applet;
- then, I move an <iframe/> tag to another cell/div, JVM destroys my applet and creates a new one, however the browser have lost the reference (or it holds the reference to the old applet which is destroyed) - so, I cannot call any applet method from JavaScript anymore.
And one more thing, when applet is being recreated in this way, it is no longer re-draws itselft. Update and Paint methods are no longer called inside an applet even if to call them by hand (repaint function).
Btw, this is not reproduces on MS JVM :) That's strange problem...
Any help will be really appreciated.
Thanks,
# 2
More info:
- IE6 + SP2
- Sun JVM 1.5.0.9 or 1.5.0.11 or 1.6.0 (reproduces the issue)
I am looking for a solution for this problem because we are trying to move from Microsoft JVM to Sun. However, this issue holds us from making the final release.
If you feel like you can help, I will be glad to hear any ideas / suggestions / considerations about this problem:
Still, we are looking for the answers to the following questions:
- Why Sun JVM forces applet to re-create instead of keeping it running in this case?
- What are the possible solutions / workarounds for this issue?
I you know were I can get the answers, please tell me.
Looking forward to your replies.
Thanks,