Adobe Extending Dreamweaver CS4 Bedienungsanleitung Seite 289

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 387
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 288
283
EXTENDING DREAMWEAVER CS4
Server behaviors
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
You can find server behaviors by:
Writing search patterns
Using optional search patterns
Writing search patterns
To update or delete server behaviors, provide a way for Dreamweaver to find each instance in a document. It requires
a
quickSearch tag and at least one searchPattern tag, which is contained within the searchPatterns tag.
The quickSearch tag must be a string, not a regular expression, that indicates that the server behavior exists on the
page. It is not case-sensitive. It must be short and unique, and it must avoid spaces and other sections that the user can
change. 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 identify the directive and extract 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>
The search string is defined as a regular expression by starting and ending with a slash (/). An i follows the slash, which
means that it is not case-sensitive. Within the regular expression, special characters such as parentheses () and periods
(.) are escaped by preceding them with a backslash (\). The two parameters
rs and new_url are extracted from the
string by using parenthetical subexpressions (the parameters must be enclosed in parentheses). In this example,
(\w+)
and
([^\r\n]*) indicate the parameters. These values correspond to the regular expression values that $1 and $2
normally returns.
Seitenansicht 288
1 2 ... 284 285 286 287 288 289 290 291 292 293 294 ... 386 387

Kommentare zu diesen Handbüchern

Keine Kommentare