Updating server behaviors – Adobe Extending Dreamweaver CS4 User Manual
Page 293
287
EXTENDING DREAMWEAVER CS4
Server behaviors
The tag/attribute combination (see the previous example) does not apply to translation because Dreamweaver always
translates to straight text in the JavaScript layer. File dependency checking, path fixing, and so on occurs in the C layer.
In the C layer, Dreamweaver internally splits the document into directives (straight text) and tags (parsed into an
efficient tree structure).
Updating server behaviors
You can update server behaviors by:
•
Replacement update
•
Precision update
Replacement update
By default, participant EDML files do not have an
tag, and instances of the participant are updated
in the document by replacing them entirely. When a user edits an existing server behavior and clicks OK, any
participant that contains a parameter whose value has changed is removed. Then, the participant is reinserted with the
new value in the same location.
If the user customizes participant code in the document, the participant might not be recognized if the search patterns
look for the old code. Shorter search patterns can let the user customize the participant code in their document.
However, updating the server behavior instance can cause the replacement of the participant, which loses the custom
edits.
Precision update
In some cases, it is desirable to let users customize the participant code after it is inserted in the document. This
situation can be achieved by limiting the search patterns and providing update patterns in the EDML file. After you
add the participant to the page, the server behavior updates only specific parts of it. The following example shows a
simple participant with two parameters:
<% if (Recordset1.EOF) Response.Redirect("some_url_here") %>
This example might use the following search patterns:
/if\s*\((\w+)\.EOF\)\s*Response\.Redirect\("([^\r\n]*)"\)/i
The user could add another test to a particular instance of this code, as shown in the following example:
<% if (Recordset1.EOF || x > 2) Response.Redirect("some_url_here") %>
The search patterns fail because they are looking for a parenthesis after the
EOF
parameter. To make the search patterns
more forgiving, you can shorten them by splitting them up, as shown in the following example: