The Data Sources API

 < Day Day Up > 

The functions in the Data Sources API let you find, add, edit, and delete data sources and also generate and inspect dynamic data objects.

addDynamicSource()

Availability

Dreamweaver UltraDev 1.

Description

This function adds a dynamic data source. Because there is one implementation of this function in each data source file, Dreamweaver calls the appropriate implementation of the addDynamicSource() function when you select a data source from the Plus (+) menu.

For example, for recordsets or commands, Dreamweaver calls the dw.serverBehaviorInspector.popupServerBehavior() function, which inserts a new server behavior into the document. For request, session, and application variables, Dreamweaver displays an HTML/JavaScript dialog box to collect the name of the variable; the behavior stores the variable name for future use.

After the addDynamicSource() function returns, Dreamweaver erases the contents of the data source tree and calls the findDynamicSources() and generateDynamicSourceBindings() functions to repopulate the data source tree.

Returns

Dreamweaver expects nothing.

deleteDynamicSource()

Availability

Dreamweaver UltraDev 1.

Description

Dreamweaver calls this function when a user selects a data source in the tree and clicks the Minus (-) button.

For example, in Dreamweaver, if the selection is a recordset or command, the deleteDynamicSource() function calls the dw.serverBehaviorInspector.deleteServerBehavior() function. If the selection is a request, session, or application variable, the function remembers that the variable was deleted and does not continue to display it. After the deleteDynamicSource() function returns, Dreamweaver erases the contents of the data source tree and calls the findDynamicSources() and generateDynamicSourceBindings() functions to get a new list of all the data sources for the user's document.

Arguments

 sourceName, bindingName 

  • The sourceName argument is the name of the top-level node to which the child node is associated.

  • The bindingName argument is the name of the child node.

Returns

Dreamweaver expects nothing.

displayHelp()

Description

If this function is defined, a Help button appears below the OK and Cancel buttons in the dialog box. This function is called when the user clicks the Help button.

Arguments

None.

Returns

Dreamweaver expects nothing.

Example

 // The following instance of displayHelp() opens // a file (in a browser) that explains how to use // the extension. function displayHelp(){   var myHelpFile = dw.getConfigurationPath() +     '/ExtensionsHelp/superDuperHelp.htm';   dw.browseDocument(myHelpFile); } 

editDynamicSource()

Availability

Dreamweaver MX.

Description

This function is called when the user double-clicks a data source name in the Bindings panel to edit the data source. You can implement this function to handle user edits in the tree. Otherwise, the server behavior that matches the data source is automatically invoked. The extension developer can use this function to override the default implementation of server behaviors and provide a custom handler.

Arguments

 sourceName, bindingName 

  • The sourceName argument is the name of the top-level node to which the child node is associated.

  • The bindingName argument is the name of the child node.

Returns

Dreamweaver expects a Boolean value: TRue if the function has handled the edit; false otherwise.

findDynamicSources()

Availability

Dreamweaver UltraDev 1.

Description

This function returns the top-level nodes from the data source tree that appears in the Dynamic Data or Dynamic Text dialog box or in the Bindings panel. Each data source file has an implementation of the findDynamicSources() function. When Dreamweaver refreshes the tree, Dreamweaver reads through all the files in the DataSources folder and calls the findDynamicSources() function in each file.

Returns

Dreamweaver expects an array of JavaScript objects where each object can have as many as five properties, which are described in the following list:

  • The title property is the label string that appears to the right of the icon for each parent node. The title property is always required.

  • The imageFile property is the path of a file that contains the icon (a GIF image), which represents the parent node in the tree control in the Dynamic Data or Dynamic Text dialog box or in the Bindings panel. This property is required.

  • The allowDelete property is optional. If this property is set to false, when the user clicks this node in the Bindings panel, the Minus (-) button is disabled. If this property is set to TRue, the Minus (-) button is enabled. If the property is not defined, the default is true.

  • The dataSource property is the simple name of the file in which the findDynamicSources() function is defined. For example, the findDynamicSources() function in the Session.htm file, which is located in the Configuration/DataSources/ASP_Js folder, sets the dataSource property to session.htm. This property is required.

  • The name property is the name of the server behavior that is associated with the data source, if one exists. Some data sources, such as recordsets, are associated with server behaviors. When you create a recordset and name it rsAuthors, the name attribute must equal rsAuthors. The name property is always defined, but can be an empty string ("") if no server behavior is associated with the data source (such as a session variable).

NOTE

A JavaScript class that defines these properties exists in the DataSourceClass.js file, which is located in the Configuration/Shared/Common/Scripts folder.


generateDynamicDataRef()

Availability

Dreamweaver UltraDev 1.

Description

This function generates the dynamic data object for a child node.

Arguments

 sourceName, bindingName 

  • The sourceName argument is the name of the top-level node that is associated with the child node.

  • The bindingName argument is the name of the child node from which you want to generate a dynamic data object.

Returns

Dreamweaver expects a string, which can be passed to the formatDynamicDataRef() function to format it before inserting it in a user's document.

generateDynamicSourceBindings()

Availability

Dreamweaver UltraDev 1.

Description

This function returns the children of a top-level node.

Arguments

 sourceName 

  • The sourceName argument is the name of the top-level node whose children you want to return.

Returns

Dreamweaver expects an array of JavaScript objects where each object can have as many as four properties, which are described in the following list:

  • The title property is the label string that appears on the right of the icon for each parent node. This property is required.

  • The allowDelete property is optional. If this property is set to the value false, when the user clicks this node in the Bindings panel, the Minus (-) button is disabled. If this property is set to the value TRue, the Minus (-) button is enabled. If the property is not defined, the default is the value TRue.

  • The dataSource property is the simple name of the file in which the findDynamicSources() function is defined. For example, the findDynamicSources() function in the Session.htm file, which is located in the Configuration/DataSources/ASP_Js folder, sets the dataSource property to session.htm. This property is required.

  • The name property is the name of the server behavior that is associated with the data source, if one exists. It is a required property. Some data sources, such as recordsets, are associated with server behaviors. When you create a recordset and name it rsAuthors, the name property must equal rsAuthors. Other data sources, such as session variables, do not have a corresponding server behavior. Their name property must be the empty string ("").

NOTE

A JavaScript class that defines these properties exists in the DataSourceClass.js file, which is located in the Configuration/Shared/Common/Scripts folder.


inspectDynamicDataRef()

Availability

Dreamweaver UltraDev 1.

Description

This function determines the corresponding node in the data source tree from a dynamic data object. The inspectDynamicDataRef() function takes the string that Dreamweaver passes in and compares it to the string that generateDynamicDataRef() returns for each node in the tree. If a match is found, the inspectDynamicDataRef() function indicates which node in the tree matches the passed-in string. The function identifies the node by using an array that contains two elements. The first element is the name of the parent node, and the second element is the name of the child node. If no match is found, the inspectDynamicDataRef() function returns an empty array.

Each implementation of the inspectDynamicDataRef() function checks only for matches of its own object type. For example, the recordset implementation of the inspectDynamicDataRef() function finds a match only if the passed-in string matches a recordset node in the tree.

Arguments

 string 

  • The string argument is the dynamic data object.

Returns

Dreamweaver expects an array of two elements (parent name and child name) for the matched node; it returns a null value if no matches are found.

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net