Passing Data Between Nested Custom Tags; What Data Is Accessible; Where Is Data Accessible; High-Level Data Exchange - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

78

Passing Data Between Nested Custom Tags

A key custom tag feature is the ability of collaborating custom tags to exchange
complex data without user intervention and without violating the encapsulation of a
tag's implementation outside the circle of its collaborating tags. The following issues
need to be addressed:
What data should be accessible?
Which tags can communicate to which tags?
How are the source and targets of the data exchange identified?
What CFML mechanism is used for the data exchange?

What data is accessible?

To enable developers to obtain maximum productivity in an environment with few
restrictions, CFML custom tags can expose all their data to collaborating tags.
When you develop custom tags, you should document all variables that collaborating
tags can access and/or modify. When your custom tags collaborate with other custom
tags, you should make sure that they do not modify any undocumented data.
To preserve encapsulation, put all tag data access and modification operations into
custom tags. For example, rather than simply documenting that the variable
MyQueryResults in a tag's implementation holds an important query result set and
expecting users of the custom tag to manipulate MyQueryResults directly, create
another nested custom tag that manipulates MyQueryResult. This protects the users of
the custom tag from changes in the tag's implementation.

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, they have no
instance data. The tag's data access is therefore restricted to ancestors only. Ancestor
data will be 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 back up the
hierarchy of nested tags, including those in included pages and custom tag references,
to the start of the base page for the request. CFINCLUDE tags and custom tags will
appear on the tag context stack.

High-level data exchange

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 CFHTTP/CFHTTPPARAM and
CFTREE/CFTREEITEM. You can use the CFASSOCIATE tag to encapsulate this
processing.
Developing Web Applications with ColdFusion

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents