Dreamweaver users can add dynamic data by using the Bindings panel. The dynamic data objects that are shown on the Plus (+) menu are based on the server model that is specified for the page. For example, users can insert recordsets, commands, request variables, session variables, and application variables for ASP applications. For related information, see the function dreamweaver.dbi.getDataSources() in the Dreamweaver API Reference.

The following steps describe the process that is involved in adding dynamic data:

  1. When the user clicks the Plus (+) menu in the Bindings panel, a pop-up menu appears.

    To determine the contents of the menu, Dreamweaver first looks for a DataSources.xml file in the same folder as the data sources (for example, Configuration/DataSources/ASP_Js/DataSources.xml). The DataSources.xml file describes the contents of the pop-up menu; it contains references to the HTML files that are placed in the pop-up menu.

    Dreamweaver checks each referenced HTML file for a title tag. If the file contains a title tag, the content of the title tag appears in the menu. If the file does not contain a title tag, the filename is used in the menu.

    After Dreamweaver finishes reading the DataSources.xml file, it searches the rest of the folder for other items that ought to appear in the menu. It does the same if the DataSources.xml file does not exist. If Dreamweaver finds files in the main folder that aren’t in the menu, it adds them to the menu. If subfolders contain files that aren’t in the menu, Dreamweaver creates a submenu and adds those files to the submenu.

  2. When the user selects an item from the Plus (+) menu, Dreamweaver calls the addDynamicSource() function. It is done so that code for the data source is added to the document of the user.

  3. Dreamweaver goes through each file in the appropriate server model folder, calling the findDynamicSources() function in each file. For each value in the returned array, Dreamweaver calls the generateDynamicSourceBindings() function in the same file. It is done to get a new list of all the fields in each data source for the document of the user. Those fields are presented to the user as a tree control in the Dynamic Data or the Dynamic Text dialog box or in the Bindings panel. The data source tree for an ASP document appears as shown in the following example:

     Recordset (Recordset1) 
        ColumnOneInRecordset 
        ColumnTwoInRecordset 
    Recordset (Recordset2) 
        ColumnOfRecordset 
    Request 
        NameOfRequestVariable 
        NameOfAnotherRequestVariable 
    Session 
        NameOfSessionVariable
  4. If the user double-clicks a data source name in the Bindings panel, Dreamweaver calls the editDynamicSource() function to handle editing within the tree.

  5. If the user clicks the Minus (-) button, Dreamweaver gets the current node selection from the tree and passes it to the deleteDynamicSource() function. The function deletes the code that was added earlier with the addDynamicSource() function. If it cannot delete the current selection, the function returns an error message. After the deleteDynamicSource() function returns, Dreamweaver refreshes the data source tree by calling the findDynamicSources() and the generateDynamicSourceBindings() functions.

  6. If the user selects a data source and clicks OK in the Dynamic Data or the Dynamic Text dialog box, Dreamweaver calls the generateDynamicDataRef() function. It does the same when the user clicks Insert or Bind in the Bindings panel. The return value is inserted in the document at the current insertion point.

  7. If the user edits a dynamic data object using the Dynamic Data, the selection in the data source tree must be initialized to the object. Same is the case if the user edits a dynamic data object using the Dynamic Text dialog box. To initialize the tree control, Dreamweaver goes through each file in the appropriate server model folder. For example, the Configuration/DataSources/ASP_Js folder. Dreamweaver goes through each file calling the implementation of the inspectDynamicDataRef() function.

    Dreamweaver calls the inspectDynamicDataRef() function to convert the dynamic data object back from the code in the user document to an item in the tree. (This process is the reverse of what occurs when the generateDynamicDataRef() function is called.) If the inspectDynamicDataRef() function returns an array that contains two elements, Dreamweaver provides visual cues to the tree item that is bound to the current selection.

  8. Every time the user changes the selection, Dreamweaver calls the inspectDynamicDataRef() function. Dreamweaver does it to determine whether the new selection is dynamic text or a tag with a dynamic attribute. If it is dynamic text, Dreamweaver displays the bindings for the current selection in the Bindings panel.

  9. It is possible to change the data format for a dynamic text object or a dynamic attribute that the user has already added to the page. To do it, use the Dynamic Data or the Dynamic Text dialog box or the Bindings panel. When the format changes, Dreamweaver calls the generateDynamicDataRef() function to get the string to insert into the document of the user. Then it passes that string to the formatDynamicDataRef() function (see formatDynamicDataRef()). The string that the formatDynamicDataRef() function returns is inserted in the document of the user.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy