The Connection API
105
The Connection API
To create a new type of connection, including the dialog box with which users interact, you must
implement the following three functions:
findConnection()
,
inspectConnection()
, and
applyConnection()
. You write these three functions and include them in the JavaScript
implementation file that is associated with your new connection type (see Step 2
“Create a
JavaScript file that implements at least the following elements:” on page 104
).
The
applyConnection()
function returns an HTML source within an include file. You can see
examples of the HTML source in
“The generated include file” on page 108
. The
findConnection()
function takes the HTML source and extracts its properties. You can
implement
findConnection()
to use the search patterns in XML files to extract the information
that returns from
applyConnection()
. For an example of such an implementation, see the
following two JavaScript files:
•
connection_ado_conn_string.js
is located in Configuration/Connections/ASP_Js folder.
•
connection_common.js
is located in Configuration/Connections/Shared folder.
When the user opens a site, Dreamweaver goes through each file in the Connections folder, opens
it, and passes the contents to
findConnection()
. If the contents of a file match the criteria for a
valid connection,
findConnection()
returns a connection object. Dreamweaver then lists all the
connection objects in the Database Explorer panel.
When the user opens a connection dialog box and selects to create a new connection or duplicate
or edit an existing connection, Dreamweaver calls the
inspectConnection()
function and passes
back the same connection object that
findConnection()
created. This process lets Dreamweaver
populate the dialog box with the connection information.
When the user clicks OK in a connection dialog box, Dreamweaver calls the
applyConnection()
function to build the HTML, which is placed in the connection include file
that is located in the Configuration/Connections folder. The
applyConnection()
function
returns an empty string that indicates there is an error in one of the fields and the dialog box
should not be closed. The include file has the default file extension type for the current server
model.
When the user adds to the page a server behavior that uses the connection, such as a recordset or
a stored procedure, Dreamweaver adds a statement to the page that includes the connection
include file.
findConnection()
Availability
Dreamweaver UltraDev 4.
Description
Dreamweaver calls this function to detect a connection in the specified HTML source and to
parse the connection parameters. If the contents of this source file match the criteria for a valid
connection,
findConnection()
returns a connection object; otherwise, this function returns a
null
value.
Argument
htmlSource
000_DW_API_Print.book Page 105 Wednesday, August 20, 2003 9:14 AM
Summary of Contents for DREAMWEAVER MX 2004-DREAMWEAVER API
Page 1: ...Dreamweaver API Reference...
Page 24: ...24 Contents...
Page 32: ......
Page 70: ...70 Chapter 5 Fireworks Integration...
Page 76: ...76 Chapter 6 Flash Integration...
Page 116: ...116 Chapter 9 The JavaBeans API...
Page 140: ......
Page 152: ...152 Chapter 11 Application...
Page 218: ...218 Chapter 12 Workspace...
Page 248: ...248 Chapter 13 Site...
Page 292: ...292 Chapter 14 Document...
Page 378: ...378 Chapter 17 Design...
Page 430: ...430 Chapter 18 Code...
Page 486: ...486 Index...