Using Tag Attributes Summary - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Variables created within a custom tag are deleted when the processing of the tag terminates.
Therefore, if you want to pass information back to the calling page, you must write that
information back to the Caller scope of the calling page. You cannot access the custom tag's
variables outside the custom tag itself.
For example, use the following code in the getmd.cfm page to set the variable Doctor on the
calling page:
<cfset Caller.Doctor="Doctor " & Attributes.Name>
If the variable Doctor does not exist in the calling page, this statement creates it. If the variable
exists, the custom tag overwrites it.
The following figure shows the relationship between the variables on the calling page and the
custom tag:
calling page
One common technique used by custom tags is for the custom tag to take as input an attribute
containing the name of the variable to use to pass back results. For example, the calling page
passes returnHere as the name of the variable to use to pass back results:
<cf_mytag resultName="returnHere">
In mytag.cfm, the custom tag passes back its results using the following code:
<cfset "Caller.#Attributes.resultName#" = result>
Tip: Be careful not to overwrite variables in the calling page from the custom tag. You should adopt a
naming convention to minimize the chance of overwriting variables. For example, prefix the returned
variable with customtagname_, where customtagname is the name of the custom tag.
Note: Data pertaining to the HTTP request or to the current application is visible in the custom tag
page. This includes the variables in the Form, Url, Cgi, Request, Cookies, Server, Application,
Session, and Client scopes.

Using tag attributes summary

Custom tag attribute values are passed from the calling page to the custom tag page as name-value
pairs. CFML custom tags support required and optional attributes. Custom tag attributes
conform to the following CFML coding standards:
ColdFusion passes any attributes in the Attributes scope.
Use the
Attributes.attribute_name
distinguish them from custom tag page local variables.
Attributes are case-insensitive.
Attributes can be listed in any order within a tag.
Attribute name-value pairs for a tag must be separated by a space in the tag invocation.
Passed values that contain spaces must be enclosed in double-quotes.
178
Chapter 9: Creating and Using Custom CFML Tags
getmd.cfm
syntax when referring to passed attributes to

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents