Server behavior techniques
369
Server behavior techniques
This section covers the common and advanced techniques that create and edit server
behaviors. Most of the suggestions involve specific settings in the EDML files.
Finding server behaviors
Writing search patterns
In order to update or delete server behaviors, you must provide a
way for Dreamweaver to find each instance in a document. This requires a
quickSearch
tag
and at least one
searchPattern
tag, which is contained within the
searchPatterns
tag.
The
quickSearch
tag should be a string, not a regular expression, that indicates that the
server behavior might exist on the page. It is not case-sensitive. It should be short and unique,
and it should avoid spaces and other sections that can be changed by the user. The following
example shows a participant that consists of the simple ASP JavaScript tag:
<% if (Recordset1.EOF) Response.Redirect("some_url_here") %>
In the following example, the
quickSearch
string checks for that tag:
<quickSearch>Response.Redirect</quickSearch>
For performance reasons, the
quickSearch
pattern is the beginning of the process of finding
server behavior instances. If this string is found in the document and the participant identifies
a server behavior (in the group file,
partType="identifier"
for this participant), the related
server behavior files are loaded and the
findServerBehaviors()
function is called. If your
participant has no reliable strings for which to search (or for debugging purposes), you can
leave the
quickSearch
string empty, as shown in the following example:
<quickSearch></quickSearch>
In this example, the server behavior is always loaded and can search the document.
Next, the
searchPattern
tag searches the document more precisely than the
quickSearch
tag and extracts parameter values from the participant code. The search patterns specify where
to search (the
whereToSearch
attribute) with a series of
searchPattern
tags that contain
specific patterns. These patterns can use simple strings or regular expressions. The previous
example code is an ASP directive, so the
whereToSearch="directive"
specification and a
regular expression identifies the directive and extracts the parameters, as shown in the
following example:
<quickSearch>Response.Write</quickSearch>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="rs,new__url">
/if\s*\((\w+)\.EOF\)\s*Response\.Redirect\("([^\r\n]*)"\)/i
</searchPattern>
</searchPatterns>
Содержание DREAMWEAVER 8-EXTENDING DREAMWEAVER
Страница 1: ...Extending Dreamweaver...
Страница 8: ...8 Contents...
Страница 14: ...14 Introduction...
Страница 16: ......
Страница 54: ...54 Customizing Dreamweaver...
Страница 96: ...96 Customizing Code View...
Страница 98: ......
Страница 110: ...110 Extending Dreamweaver...
Страница 138: ......
Страница 166: ...166 Insert Bar Objects...
Страница 180: ...180 Commands...
Страница 248: ...248 Toolbars...
Страница 260: ...260 Reports...
Страница 278: ...278 Tag Libraries and Editors...
Страница 288: ...288 Property Inspectors...
Страница 378: ...378 Server Behaviors...
Страница 398: ...398 Data Sources...
Страница 432: ...432 Server Models...
Страница 456: ...456 Data Translators...
Страница 482: ......
Страница 492: ...492 The Shared Folder...