Operation Manual

572
USING DREAMWEAVER
Making pages dynamic
Last updated 3/28/2012
<CFSTOREDPROC procedure="proc1"
datasource=#MM_connection1_DSN#
username=#MM_connection1_USERNAME#
password=#MM_connection1_PASSWORD#>
<CFPROCPARAM type="IN" dbvarname="@CategoryId" value="#Form.CategoryId#"
cfsqltype="CF_SQL_INTEGER">
<CFPROCPARAM type="IN" dbvarname="@Year" value="#Form.Year#"
cfsqltype="CF_SQL_INTEGER">
<CFPROCPARAM type="IN" dbvarname="@ISBN" value="#Form.ISBN#"
cfsqltype="CF_SQL_VARCHAR">
</CFSTOREDPROC>
Note: Parameter arrays cannot be used outside of a loop except as part of a conditional directive expression.
Using the loop directive’s _length and _index variables
The loop directive includes two built-in variables that you can use for embedded if conditions. The variables are:
_length and _index. The _length variable evaluates to the length of the arrays processed by the loop directive, while
the
_index variable evaluates to the current index of the loop directive. To ensure that the variables are only
recognized as directives, and not as actual parameters to be passed into the loop, do not enclose either variable in
@@s.
An example of using built-in variables is to apply them to the import attribute of the page directive. The import
attribute requires comma separation of packages. If the
loop directive extends around the entire import attribute, you
would only output the attribute name
import= on the first iteration of the loop—this includes the closing double quote
(")—and not output a comma on the last iteration of the loop. Using the built-in variable, you can express this as
follows:
<@loop (@@Import@@)@>
<@ if(_index == 0)@>import="
<@endif@>@@Import@@<@if (_index == _length-1)@>"<@else@>,
<@ endif @>
<@endloop@>
Request a parameter for the server behavior
Server behaviors often require that the page designer supply a parameter value. This value must be inserted before the
server behavior’s code is inserted into the page.
You create the dialog box by defining the designer-supplied parameters in the code. Then you generate a dialog box
for the server behavior, which prompts the page designer for a parameter value.
Note: A parameter is added to your code block without your intervention if you specify that your code should be inserted
relative to a specific tag chosen by the page designer (that is, you chose Relative to a Specific Tag in the Insert Code pop-up
menu). The parameter adds a tag menu to the behavior’s dialog box to let the page designer select a tag.
Define the parameter in the server behavior code
1 Enter a parameter marker in the code where you want to insert the supplied parameter value. The parameter has
the following syntax:
@@parameterName@@
2 Enclose the formParam string in parameter markers (@@):
<% Session("lang_pref") = Request.Form("@@formParam@@"); %>
For example, if the server behavior contains the following code block:
<% Session("lang_pref") = Request.Form("Form_Object_Name"); %>