
A simple data source example 383
When a user clicks on the Bindings Plus (+) menu, Dreamweaver searches the DataSources
folder for the current server model to gather all available data sources defined in the folder’s
HTML (HTM) files. So, to make a new data source available to the user, you need to create a
data source definition file that simply provides the name of the data source using the
TITLE
tag and the location of all supporting JavaScript files using the
SCRIPT tag.
In addition, several supporting files are necessary for implementing this data source. In
general, you might not need to use the functions in these supporting files, but they are often
useful (and necessary in this example). For example, the dwscriptsServer.js file contains the
dwscripts.stripCFOutputTags() function used in the implementation of this data source.
And, using the DataSourceClass.js file, you create an instance of the DataSource class to use as
the return value of the
findDynamicSources() function.
To create the data source definition file:
1. Create a new blank file.
2. Enter the following:
<HTML>
<HEAD>
<TITLE>MyDatasource</TITLE>
<SCRIPT SRC="../../Shared/Common/Scripts/dwscripts.js"></SCRIPT>
<SCRIPT SRC="../../Shared/Common/Scripts/dwscriptsServer.js"></SCRIPT>
<SCRIPT SRC="../../Shared/Common/Scripts/DataSourceClass.js"></SCRIPT>
<SCRIPT SRC="MyDatasource.js"></SCRIPT>
</HEAD>
<body></body>
</HTML>
3.
Save the file as MyDatasource.htm in the Configuration/DataSources/ColdFusion folder.
Creating the EDML file
The EDML file defines the code that Dreamweaver inserts into the document to represent the
data source value. (For more information about EDML files, see Chapter 15, “Server
Behaviors,” on page 321). When a user adds a particular value from a data source to a
document, Dreamweaver inserts the code that will translate into the actual value at runtime.
The participant EDML file defines the code for the document (for more information, see
“Participant EDML files” on page 347).
For the MyDatasource Variable, you want Dreamweaver to insert the ColdFusion code
<cfoutput>#MyXML.variable#</cfoutput> where variable is the value the user wants
from the data source.
Komentarze do niniejszej Instrukcji