Macromedia dreamweaver 8-extending dreamweaver User Manual

Page of 504
The Server Behavior API
329
The Server Behavior API
You can manage server behaviors with the following API functions.
analyzeServerBehavior()
Availability
Dreamweaver UltraDev 1
Description
Lets server behaviors set their 
incomplete
 and 
deleted
 properties. 
After the 
findServerBehaviors()
 function is called for every server behavior on the page, 
an array of all the behaviors in the user’s document appears. The 
analyzeServerBehavior()
 
function is called for each JavaScript object in this array. For example, for a Dynamic Text 
behavior, Dreamweaver calls the 
analyzeServerBehavior()
 function in the 
DynamicText.htm (or DynamicText.js) file. 
One purpose of the 
analyzeServerBehavior()
 function is to finish setting all the properties 
(
incomplete
participants
selectedNode
, and 
title
) on the behavior object. Sometimes 
it’s easier to perform this task after the 
findServerBehaviors()
 function generates the 
complete list of server behaviors in the user’s document.
The other purpose of the 
analyzeServerBehavior()
 function is to notice when two or 
more behaviors refer to the same tag in the user’s document. In this case, the 
deleted
 
property removes all but one behavior from the array.
Suppose the Recordset1, DynamicText1, and DynamicText2 server behaviors are on a page. 
Both DynamicText server behaviors need Recordset1 to exist on the page. After the server 
behaviors are found with the 
findServerBehaviors()
 function, Dreamweaver calls the 
analyzeServerBehavior()
 function for the three server behaviors. When the 
analyzeServerBehavior()
 function is called for DynamicText1, the function searches the 
array of all the server behavior objects on the page, looking for the one that belongs to 
Recordset1. If a server behavior object that belongs to Recordset1 cannot be found, the 
incomplete
 property is set to the value 
true
 so that an exclamation point appears in the 
Server Behaviors panel, which alerts the user that a problem exists. Similarly, when the 
analyzeServerBehavior()
 function is called for DynamicText2, the function searches for 
the object that belongs to Recordset1. Because Recordset1 does not depend on other server 
behaviors, it does not need to define the 
analyzeServerBehavior()
 function in this 
example.