I have jsf/xhtml page in which there are several buttons which all launch the same applet but with different initial values.
The point is to avoid launching several instances of the applet at the same time. That means a user can not have several open applets if he clicks on some of those buttons.
If an applet is currently open, and the user clicks on another button to launch a new applet, he should get an error message that an instance of the applet is open and he can not open a new one. Once the currently open applet is closed, the user can launch a new one by clicking on another button.
For that I used a boolean in init method of the applet. When initializing the applet I set it to true and when submitting or closing the applet, I set this boolean to false within the stop() method which is called while submitting or closing.
The problem: if an applet is open, I click a new button... it do not launch a new applet as this boolean is true. Every things seem good.... but if I click on a button which is previously clicked (used to launch an instance of the applet and that applet is now closed)... it closes the currently loaded applet and load a new one with the initial values of the clicked button. I traced the code, and I saw that when I click a previously clicked button (used to launch an instance of the applet and that applet is now closed) it call first the stop method of the open applet and thus that boolean value becomes false and then it thus initialize a new applet. but when I click on a new button (never previously used to launch the applet), it do not call the stop method and thus a new one can not be initialized as the boolean is currently true.
I have no idea what to do...