How the Server Behavior API functions are called
The Server Behavior API functions are called in the following scenarios:
- The
findServerBehaviors()function is called when the document opens and again when the participant is edited. It searches the user's document for instances of the server behavior. For each instance it finds, thefindServerBehaviors()function creates a JavaScript object, and uses JavaScript properties to attach state information to the object. - If it is implemented, Adobe Dreamweaver calls the
analyzeServerBehavior()function for each behavior instance that is found in the user's document after all thefindServerBehaviors()functions are called.When the
findServerBehaviors()function creates a behavior object, it usually sets the four properties (incomplete,participants,selectedNode, andtitle). However, it is sometimes easier to delay setting some of the properties until all the other server behaviors find instances of themselves. For example, the Move To Next Record behavior has two participants; a link object and a recordset object. Rather than finding the recordset object in itsfindServerBehaviors()function, wait until the recordset behavior'sfindServerBehaviors()function runs because the recordset finds all instances of itself.When the Move To Next Record behavior's
analyzeServerBehavior()function is called, it gets an array that contains all the server behavior objects in the document. The function can look through the array for its recordset object.Sometimes during analysis, a single tag in the user's document is identified by two or more behaviors as being an instance of that behavior. For example, the
findServerBehaviors()function for the Dynamic Attribute behavior might detect an instance of the Dynamic Attribute behavior that is associated with aninputtag in the user's document. At the same time, thefindServerBehaviors()function for the Dynamic Textfield behavior might look at the sameinputtag and detect an instance of the Dynamic Textfield behavior. As a result, the Server Behaviors panel shows the Dynamic Attribute block and the Dynamic Textfield. To correct this problem, theanalyzeServerBehavior()functions need to delete all but one of these redundant server behaviors.To delete a server behavior, an
analyzeServerBehavior()function can set thedeletedproperty of any server behavior to the valuetrue. If thedeletedproperty still has the valuetruewhen Adobe Dreamweaver finishes calling theanalyzeServerBehavior()functions, the behavior is deleted from the list. - When the user clicks the Plus (+) button in the Server Behaviors panel, the pop-up menu appears.
To determine the content of the menu, Adobe Dreamweaver first looks for a ServerBehaviors.xml file in the same folder as the behaviors. ServerBehaviors.xml references the HTML files that should appear in the menu.
If the referenced HTML file contains a title tag, the contents of the title tag appear in the menu. For example, if the ServerBehaviors/ASP_Js/ GetRecords.htm file contains the tag
<title>Get More Records</title>, the text Get More Records appears in the menu.If the file does not contain a title tag, the filename appears in the menu. For example, if GetRecords.htm does not contain a title tag, the text GetRecords appears in the menu.
If there is no ServerBehaviors.xml file or the folder contains one or more HTML files that are not mentioned in ServerBehaviors.xml, Adobe Dreamweaver checks each file for a title tag and uses the title tag or filename to populate the menu.
If you do not want a file that is in the ServerBehaviors folder to appear in the menu, put the following statement on the first line in the HTML file:
<!-- MENU-LOCATION=NONE -->
- When the user selects an item from the menu, the
canApplyServerBehavior()function is called. If that function returns atruevalue, a dialog box appears. When the user clicks OK, theapplyServerBehavior()function is called. - If the user edits an existing server behavior by double-clicking it, Adobe Dreamweaver displays the dialog box, executes the
onLoadhandler on theBODYtag, if one exists, and then calls theinspectServerBehavior()function. TheinspectServerBehavior()function populates the form elements with the current parameter values. When the user clicks OK, Adobe Dreamweaver calls theapplyServerBehavior()function again. - If the user clicks the Minus (-) button, the
deleteServerBehavior()function is called. ThedeleteServerBehavior()function removes the behavior from the document. - When the user selects a server behavior and uses the Cut or Copy commands, Adobe Dreamweaver passes the object that represents the server behavior to its
copyServerBehavior()function. ThecopyServerBehavior()function adds any other properties to the server behavior object that are needed to paste it later.After the
copyServerBehavior()function returns, Adobe Dreamweaver converts the server behavior object to a form that can be put on the Clipboard. When Adobe Dreamweaver converts the object, it deletes all the properties that reference objects; every property on the object that is not a number, Boolean value, or string is lost.When the user uses the Paste command, Adobe Dreamweaver unpacks the contents of the Clipboard and generates a new server behavior object. The new object is identical to the original, except that it does not have properties that reference objects. Adobe Dreamweaver passes the new server behavior object to the
pasteServerBehavior()function. ThepasteServerBehavior()function adds the behavior to the user's document. After thepasteServerBehavior()function returns, Adobe Dreamweaver calls thefindServerBehaviors()function to get a new list of all the server behaviors in the user's document.
Users can copy and paste behaviors from one document to another. The copyServerBehavior() and pasteServerBehavior() functions should rely only on properties on the behavior object to exchange information.