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
participant to be replaced, which loses the custom edits.
Precision update
In some cases, it can be 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:
<quickSearch>Response.Write</quickSearch>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="rs,new__url">
/if\s*\((\w+)\.EOF\)\s*Response\.Redirect\("([^\r\n]*)"\)/i
</searchPattern>
</searchPatterns>
The user might 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
make the search patterns more forgiving, you can shorten them by splitting them up, as shown in
the following example:
<quickSearch>Response.Write</quickSearch>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="rs">/(\w+)\.EOF/</searchPattern>
<searchPattern paramNames="new__url">
/if\s*\([^\r\n]*\)\s*Response\.Redirect\("([^\r\n]*)"/i
</searchPattern>
</searchPatterns>
These shortened search patterns are flexible, so the user can add to the code. However, if the
server behavior changes the URL, when the user clicks OK, the participant is replaced, and the
customizations are lost. To update more precisely, add an
pattern for updating each parameter:
<updatePatterns>
<updatePattern paramNames="rs">/(\b)\w+(\.EOF)/¬
</updatePattern>
<updatePattern paramNames="new__url">
/(Response\.Redirect\(")[^\r\n]*(")/i
</updatePattern>
</updatePatterns>
In update patterns, the parentheses are reversed and are placed around the text before and after
the parameter. For search patterns, use the
parameter. For update patterns, use the
parameter. All the text between the two parenthetical subexpressions is replaced with the new
value for the parameter.
updatePatterns
textBeforeParam(param)textAfterParam
(textBeforeParam)param(textAfterParam)
parameter. To
EOF
tag that contains a
Server behavior techniques
291
Need help?
Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?
Questions and answers