Adobe ColdFusion 8

Embedding Java applets

The cfapplet tag lets you embed Java applets either on a ColdFusion page or in a cfform tag. To use the cfapplet tag, you must first register your Java applet using the ColdFusion Administrator Java Applets page (under Extensions). In the ColdFusion Administrator, you define the interface to the applet, encapsulating it so that each invocation of the cfapplet tag is very simple.

The cfapplet tag within a form offers several advantages over using the HTML applet tag:

  • Return values: The cfapplet tag requires a form field name attribute, so you can avoid coding additional JavaScript to capture the applet's return values. You can reference return values like any other ColdFusion form variable: Form.variablename.
  • Ease of use: The applet's interface is defined in the ColdFusion Administrator, so each instance of the cfapplet tag in your pages only needs to reference the applet name and specify a form variable name.
  • Parameter defaults: ColdFusion uses the parameter value pairs that you defined in the ColdFusion Administrator. You can override these values by specifying parameter value pairs in the cfapplet tag.

When an applet is registered, you enter just the applet source and the form variable name:

<cfapplet appletsource="Calculator"name="calc_value">

By contrast, with the HTML applet tag, you must declare all the applet's parameters every time you want to use it in a ColdFusion page.

Registering a Java applet

Before you can use a Java applet in your ColdFusion pages, you must register the applet in the ColdFusion Administrator.

Register a Java applet

  1. Open the ColdFusion Administrator by clicking the Administrator icon in the ColdFusion Program group and entering the Administrator password.
  2. Under Extensions, click Java Applets.

    The Java Applets page appears.

  3. Click the Register New Applet button.

    The Add/Edit Applet page appears.

  4. Enter options in the applet registration fields, as described in the ColdFusion Administrator online help. Use the Add button to add parameters.
  5. Click Submit.