Top
Interstage Studio J Business Kit User's Guide
FUJITSU Software

2.3.11 Confirming Applet Termination

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.

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.

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.

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:

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.