beautypg.com

Adobe Extending Dreamweaver CS4 User Manual

Page 290

background image

284

EXTENDING DREAMWEAVER CS4

Server behaviors

Optional search patterns
Sometimes you want to identify a participant even if some parameters are not found. The participant stores some
optional information such as a telephone number. For such an example, you could use the following ASP code:

<% //address block

LNAME = "joe";
FNAME = "smith";
PHONE = "123-4567";

%>

You could use the following search patterns:

address

/LNAME\s*=\s*"([^\r\n]*)"/i
/FNAME\s*=\s*"([^\r\n]*)"/i
/PHONE\s*=\s*"([^\r\n]*)"/i

In the previous example, the telephone number must be specified. However, you can make the telephone number
optional, by adding the

isOptional

attribute, as shown in the following example:

address

/LNAME\s*=\s*"([^\r\n]*)"/i
/FNAME\s*=\s*"([^\r\n]*)"/i
/PHONE\s*=\s*"([^\r\n]*)"/i¬

Now the participant is recognized, even if the telephone number is not found.

How participants are matched
If a server behavior has more than one participant, the participants must be identified in the user document and
matched. If the user applies multiple instances of the server behavior to a document, each group of participants must
be matched accordingly. To ensure that participants are matched correctly, change or add parameters and construct
participants so they can be uniquely identified.

Matching requires some rules. Participants are matched when all parameters with the same name have the same value.
Above and below the

html

tag, there can be only one instance of a participant with a given set of parameter values.

Within the

html.../html

tags, Dreamwaever matches participants by their position relative to the selection or to

common nodes that are used for insertion.

Participants without parameters are automatically matched, as shown in the following example of a server behavior
with group file:

Test


The following example inserts two simple participants above the

html

tag:

This manual is related to the following products: