The server behavior api, Analyzeserverbehavior() – Adobe Extending Dreamweaver CS4 User Manual
Page 257
251
EXTENDING DREAMWEAVER CS4
Server behaviors
•
When the user selects a server behavior and uses the Cut or Copy commands, Dreamweaver passes the object that
represents the server behavior to its
copyServerBehavior()
function. The
copyServerBehavior()
function
adds any other properties to the server behavior object that are needed to paste it later.
After the
copyServerBehavior()
function returns, Dreamweaver converts the server behavior object to a form
that can be put on the Clipboard. When 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, 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. Dreamweaver passes the new server behavior object to the
pasteServerBehavior()
function.
The
pasteServerBehavior()
function adds the behavior to the user’s document. After the
pasteServerBehavior()
function returns, Dreamweaver calls the
findServerBehaviors()
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.
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 the 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