Adobe COLDFUSION 9 Manual page 226

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
To preserve encapsulation, place all tag data access and modification operations in custom tags. For example, rather
than documenting that the variable MyQueryResults in a tag's implementation holds a query result and expecting
users to manipulate MyQueryResults directly, create a nested custom tag that manipulates MyQueryResult. This
technique protects the users of the custom tag from changes in the tag's implementation.
Variable scopes and special variables
Use the Request scope for variables in nested tags. The Request scope is available to the base page, all pages it includes,
all custom tag pages it calls, and all custom tag pages called by the included pages and custom tag pages. Collaborating
custom tags that are not nested in a single tag can exchange data using the request structure. The Request scope is
represented as a structure named
Where is data accessible?
Two custom tags can be related in a variety of ways in a page. Ancestor and descendant relationships are important
because they relate to the order of tag nesting.
A tag's descendants are inactive while the page is executed; that is, the descendent tags have no instance data. A tag,
therefore, can only access data from its ancestors, not its descendants. Ancestor data is available from the current page
and from the whole runtime tag context stack. The tag context stack is the path from the current tag element up the
hierarchy of nested tags, including those tags in included pages and custom tag references, to the start of the base page
for the request. Both
cfinclude
High-level data exchange
Although the ability to create nested custom tags is a tremendous productivity gain, keeping track of complex nested
tag hierarchies can become a chore. The
this tag to a sub tag, you enable communication of its attributes to the base tag.
In addition, there are many cases in which descendant tags are used only as a means for data validation and exchange
with an ancestor tag, such as
encapsulate this processing.
The
tag has the following format:
cfassociate
<cfassociate baseTag="tagName" dataCollection="collectionName">
The
attribute specifies the name of the base tag that gets access to this tag's attributes. The
baseTag
attribute specifies the name of the structure in which the base tag stores the subtag data. Its default value is
AssocAttribs. ColdFusion requires a
subtag. It is convenient for keeping separate collections of attributes, one per tag type.
Note: If the custom tag requires an end tag, the code processing the structure referenced by the
must be part of end-tag code.
When
is encountered in a sub tag, the sub tag's attributes are automatically saved in the base tag. The
cfassociate
attributes are in a structure appended to the end of an array whose name is thisTag.collectionName.
The
tag performs the following operations:
cfassociate
.
Request
tags and custom tags appear on the tag context stack.
tag lets the parent know what the children are up to. By adding
cfassociate
/
and
cfhttp
cfhttpparam
cftreecftreeitem
attribute only if the base tag can have more than one type of
dataCollection
Last updated 8/5/2010
. You can use the
cfassociate
dataCollection
dataCollection
221
tag to
attribute

Advertisement

Table of Contents
loading

Table of Contents