User Guide

300 Chapter 16: Data Sources
Creating the data source definition file
First, 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 folders
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.
For a data source called MyDatasource (and with a supporting JavaScript file MyDatasource.js to
be created later), write the following data source definition file:
<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>
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, we will create an instance of the DataSource class to use as
the return value of the
findDynamicSources() function.
Next, save this definition file in the Configuration\DataSources\ColdFusion folder as
MyDatasource.htm.
Creating the EDML file
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 268).
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.
Create a file with the following content:
<participant>
<quickSearch><![CDATA[#]]></quickSearch>
<insertText
location="replaceSelection"><![CDATA[<cfoutput>#MyDatasource.@@bindingName@
@#</cfoutput>]]></insertText>
<searchPatterns whereToSearch="tag+cfoutput">
<searchPattern paramNames="sourceName,bindingName"><![CDATA[/
#(?:\s*\w+\s*\()?(MyDatasource)\.(\w+)\b[^#]*#/i]]></searchPattern>
</searchPatterns>
</participant>
Save the file in the Configuration\DataSources\ColdFusion folder as
MyDatasource_DataRef.edml.