
Embedding Java Applets
167
Embedding Java Applets
The
cfapplet
tag allows you to embed Java applets in a
cfform
. To use
cfapplet
,
you must first register your Java applet using the ColdFusion Administrator Java
Applets page (under Extensions on the Server tab). In the Administrator, you define
the interface to the applet, encapsulating it so that each invocation of the
cfapplet
tag is very simple.
The
cfapplet
tag offers several advantages over using the HTML
applet
tag:
•
Return values
Since
cfapplet
requires a form field
name
attribute, 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
Since the applet’s interface is defined in the Administrator, 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 you defined in
the Administrator. You can override these values by specifying parameter value
pairs in
cfapplet.
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 Administrator.
To register a Java applet:
1
Open the ColdFusion Administrator by clicking on the Administrator icon in the
ColdFusion Program group and entering the Administrator password (if
required).
2
Click Java Applets on Administrator Server tab to open the Java Applets page.
3
Click the Register New Applet button to open the Add/Registered Java Applet
page.
4
Enter a name for the applet that you want to register. Enter the information your
applet requires, and choose the height, width, vertical and horizontal space, and
alignment that you want. Enter the Parameter names and their default values.
5
Click Create to complete the process.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...