User Guide

Table Of Contents
Embedding Java applets 655
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 MX
Administrator Java Applets page (under Extensions). In the ColdFusion MX 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 applets interface is defined in the ColdFusion MX 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 MX 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.
<cfelseif
Form.employee_grid.rowstatus.action[counter]
is "I">
<cfquery name="InsertNewEmployee"
datasource="cfdocexamples">
INSERT into Employee (LastName, Dept_ID)
VALUES (<cfqueryparam
value="#Form.employee_grid.LastName[counter]#"
CFSQLType="CF_SQL_VARCHAR" >,
<cfqueryparam
value="#Form.employee_grid.Dept_ID[counter]#"
CFSQLType="CF_SQL_INTEGER" >)
</cfquery>
Otherwise, if the action is to insert a row,
generates a SQL INSERT query to
insert the employee’s last name and
department ID from the grid row into the
database. The INSERT statement
assumes that the DBMS automatically
increments the Emp_ID primary key. If
you use the version of the
cfdocexamples database that is
provided for UNIX installations, the
record is inserted without an Emp_ID
number.
</cfif>
</cfloop>
</cfif>
Closes the cfif tag used to select
among deleting, updating, and inserting.
Closes the loop used for each row to be
changed.
Closes the
cfif tag that surrounds all the
active code.
Code Description