Creating the JavaScript file that implements the Data Sources API functions
After you have defined the name of the data source, the name of the supporting script files, and
the code for the working Dreamweaver document, you need to write out the JavaScript functions
for Dreamweaver to provide the user with the ability to add, insert, and delete the necessary code
into a document.
Based on the construction of the Cookie Variable data source, you can implement the MyXML
data source, as shown in the following example (the MyDatasource_Variable command used in
the
addDynamicSource()
input" on page
303):
//************** GLOBALS VARS *****************
var MyDatasource_FILENAME = "REQ_D.gif";
var DATASOURCELEAF_FILENAME = "DSL_D.gif";
//****************** API **********************
function addDynamicSource()
{
MM.retVal = "";
MM.MyDatasourceContents = "";
dw.popupCommand("MyDatasource_Variable");
if (MM.retVal == "OK")
{
var theResponse = MM.MyDatasourceContents;
if (theResponse.length)
{
var siteURL = dw.getSiteRoot();
if (siteURL.length)
{
dwscripts.addListValueToNote(siteURL, "MyDatasource", theResponse);
}
else
{
alert(MM.MSG_DefineSite);
}
}
else
{
alert(MM.MSG_DefineMyDatasource);
}
}
}
function findDynamicSources()
{
var retList = new Array();
var siteURL = dw.getSiteRoot()
if (siteURL.length)
{
var bindingsArray = dwscripts.getListValuesFromNote(siteURL,
"MyDatasource");
if (bindingsArray.length > 0)
{
// Here we create an instance of the DataSource class as defined in the
// DataSourceClass.js file to store the return values.
function is defined in
"Creating the supporting command files for user
A simple data source example
301
Need help?
Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?