This section describes the confirmation process of the applet termination provided by JBK Plugin
JBK Plugin provides the functionality to confirm the termination of applets in a browser window when the user is going to close the window. The applets that use the functionality can allow or reject the termination.
If all applets in the browse window allow the termination, JBK Plugin destroys the applets and closes the window.
If some applet rejects its termination, JBK Plugin cancels to close the window. The applets continue to run.
This functionality enables an applet to prohibit its termination temporary while it access to the database, for instance.
Confirming the Termination of the Applet
To use the functionality of confirming the termination of the applet, the applet has to implement the PluginAppletCallback interface.
The PluginAppletCallback interface is provided by JBK Plugin. Its API is as shown below.
Interface:
com.fujitsu.jbk.plugin.browser.PluginAppletCallback
(extends java.lang.Object)
Methods:
destroyRequested
This method is invoked from the browser in order to confirm the termination.
public abstract boolean destroyRequested() |
true - the applet allows the termination.
false - the applet rejects the termination.
destroyCancelled
This method is invoked when some applet rejects the termination.
public abstract void destroyCancelled() |
Example
An applet confirmed the termination by the browser
import java.applet.*; import com.fujitsu.jbk.plugin.browser.PluginAppletCallback; /** * Sample applet confirmed its termination by the browser. */ public class DestroySample extends Applet implements PluginAppletCallback { /** * Invoked when JBK Plugin confirms the termination. */ public boolean destroyRequested() { // Returns false if the applet does not allow its termination. if (/* the applet does not allow its termination */) { return false; } // Returns true if the applet allow its termination. return true; } /** * Invoked when some applet rejects its termination. */ public void destroyCancelled() { // do something if you need. } } |
Note
Do not include display of a dialog box, a keyboard/mouse operation, or other processing involving a GUI operation in the destroyRequested() and destroyCancelled() methods. Otherwise, the browser may be unable to accept processing requests.
The confirmation process when several applets run in a browser window
When several applets run in one browser window, JBK Plugin invokes the destroyRequested() method of each applet in turn, and confirms the termination.
If all applets allow the termination, the browser window is closed.
If one or more applets rejects the termination, JBK Plugin stops the confirmation process, cancels the request for closing the browser window, and invokes the destroyCancelled() method of each applet in turn.
Therefore, all applets can know that some applet rejects the termination.
How to invalidate the confirmation
If the destroyRequested() method of some applet always returns false by mistake, the termination of the applet is always rejected and the browser window is no longer closed. In this case, do the following:
Create a file named "jbkplugin.shutdown" in the "class" subdirectory of the directory where JBK is installed. The file size can be zero.
If this file exists while the browser window is closing, JBK Plugin destroys all applets in the window without confirming the termination.
When the user quits the browser, JBK Plugin deletes the "jbkplugin.shutdown" file. However, it is not deleted unless the user is permitted so or it is created as a directory. Therefore, after the browser is closed, the user should check whether the file remains or not. Is it remains, please delete it manually.