DREAMWEAVER CS3
User Guide
592
When the page designer clicks the Plus (+) button on the Server Behaviors panel, the new server behavior’s title will
appear in the pop-up menu. When a designer applies an instance of a server behavior to a document, the behavior
appears in the list of applied behaviors in the Server Behaviors panel. Use the Server Behavior Title box to specify
the contents of the Plus (+) pop-up menu and the list of applied behaviors.
The initial value in the box is the name you supplied in the New Server Behavior dialog box. As parameters are
defined, the name is automatically updated so that the parameters appear inside parentheses after the server behavior
name.
Set Session Variable (@@Name@@, @@Value@@)
If the user accepts the default value, everything before the parentheses appears in the Plus (+) pop-up menu (for
example, Set Session Variable). The name plus the parameters will appear in the list of applied behaviors—for
example, Set Session Variable ("abcd", "5").
Code Block to Select
Specifies what code block is selected when the user selects the behavior in the Server Behaviors
panel.
When you apply a server behavior, one of the code blocks within the behavior is designated the “code block to select.”
If you apply the server behavior and then select the behavior in the Server Behaviors panel, the designated block is
selected in the Document window. By default, Dreamweaver selects the first code block that is not above the
html
tag. If all the code blocks are above the
html
tag, then the first one is selected. Advanced users can specify which code
block is the selected one.
Creating code blocks
The code blocks you create in the Server Behavior Builder are encapsulated in a server behavior that appears in the
Server Behaviors panel. The code can be any valid run-time code for the specified server model. For example, if you
choose ColdFusion as the document type for your custom server behavior, the code you write must be valid
ColdFusion code that runs on a ColdFusion application server.
You can create the code blocks either directly in the Server Behavior Builder, or you can copy and paste the code from
other sources. Each code block you create in the Server Behavior Builder must be a single tag or script block. If you
must insert multiple tag blocks, split them into separate code blocks.
Conditions in code blocks
Dreamweaver lets you develop code blocks that incorporate control statements that execute conditionally. The
Server Behavior Builder uses
if
,
elseif
, and
else
statements, and may also contain server behavior parameters.
This enables you to insert alternate text blocks based on the values of OR relationships among server behavior
parameters.
The following example shows the
if
,
elseif
, and
else
statements. The square brackets ([ ]) denote optional code
and the asterisk (*) denotes zero or more instances. To execute a portion of a code block or the entire code block only
if a certain condition or conditions apply, use the following syntax:
<@ if (
expression1
) @>
conditional text1
[<@ elseif (
expression2
) @>
conditional text2
]*[<@
else @>
conditional text3
]<@ endif @>
Condition expressions can be any JavaScript expression that can be evaluated using the JavaScript
eval()
function,
and may include a server behavior parameter marked by @@’s. (The @@’s distinguish the parameter from JavaScript
variables and keywords.)
September 4, 2007