Adobe COLDFUSION 9 Manual page 220

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Code
<cfset NameYouEntered="Smith">
<cfoutput>
Before you leave this page, you're
#Variables.NameYouEntered#.<br>
</cfoutput>
<cf_getmd Name="#NameYouEntered#">
<cfparam name="Attributes.Name" default="Who">
<cfset Caller.Doctor="Doctor " & Attributes.Name>
<cfoutput>
You are now #Variables.Doctor#.<br>
</cfoutput>
Passing custom tag attributes by using CFML structures
You can use the reserved attribute
attribute must reference a structure containing the attribute names as the keys and the
attributeCollection
attribute values as the values. You can freely mix
tag.
The key-value pairs in the structure specified by the
scope of the custom tag pages. This action has the same effect as specifying the
individual attributes when you call the custom tag. The custom tag page refers to the attributes passed using
the same way as it does other attributes; for example, as Attributes.CustomerName or
attributeCollection
Attributes.Department_number.
Note: You can combine tag attributes and the
when you use the
tag to invoke a custom tag. If you pass an attribute with the same name both explicitly and
cfmodule
in the
attributeCollection
corresponding attribute from the attribute collection. You cannot combine tag attributes and the
attribute when you use standard (built in) ColdFusion tags.
attributeCollection
Custom tag processing reserves the
tag attributes. If
attributeCollection
exception.
The following example uses an
<cfset zort=StructNew()>
<cfset zort.x = "-X-">
<cfset zort.y = "-Y-">
<cf_testtwo a="blab" attributeCollection=#zort# foo="16">
If testtwo.cfm contains the following code:
attributeCollection
attributeCollection
attributeCollection
attributeCollection
structure, ColdFusion passes only the tag attribute to the custom tag and ignores the
attributeCollection
does not reference such a collection, ColdFusion generates a template
attribute to pass two of four attributes:
attributeCollection
Last updated 8/5/2010
Description
In the calling page, create a variable
it the value
.
Smith
In the calling page, display the value of the
variable before calling the custom tag.
In the calling page, call the getmd custom tag and pass it the
attribute whose value is the value of the local variable
NameYouEntered
.
The custom tag page normally gets the Name variable in the
Attributes scope from the calling page. Assign it the value
the calling page did not pass an attribute.
In the custom tag page, create a variable called
Caller scope so it exists in the calling page as a local variable.
Set its value to the concatenation of the string
value of the
Attributes.Name
In the calling page, display the value of the
returned by the custom tag page. (This example uses the Variables
scope prefix to emphasize the fact that the variable is returned as a
local variable.)
to pass attributes to custom tags using a structure. The
with other attributes when you call a custom
attribute get copied into the Attributes
attributeCollection
attribute when you use a custom tag directly or
attribute for the structure holding a collection of custom
and assign
NameYouEntered
NameYouEntered
Name
if
Who
Doctor
in the
and the
"Doctor"
variable.
Doctor
variable
entries as
215

Advertisement

Table of Contents
loading

Table of Contents