182
The
<cfassociate baseTag="tagName" dataCollection="collectionName"
The
attributes. The
base tag stores the sub-tag data. Its default value is AssocAttribs. You only need to
specify a
sub tag. It is convenient for keeping separate collections of attributes, one per tag
type.
When
automatically saved in the base tag. The attributes are in a structure appended to the
end of an array whose name is 'thisTag.collectionName'.
The
<!--- Get base tag instance data --->
The CFML code accessing sub-tag attributes in the base tag could look like the
following:
<!--- Protect against no sub-tags --->
Ancestor data access
The ancestor's data is represented by a structure object that contains all the
ancestor's data.
The following functions provide access to ancestral data:
tag has the following format:
cfassociate
attribute is the name of the base tag that gets access to this tag's
baseTag
dataCollection
dataCollection
is encountered in a sub tag, the sub tag's attributes are
cfassociate
tag performs the following operations:
cfassociate
<cfset data = getBaseTagData(baseTag).thisTag>
<!--- Create a string with the attribute collection name --->
<cfset collection_Name = "data.#dataCollection#">
<!--- Create the attribute collection, if necessary --->
<cfif not isDefined(collectionName)>
<cfset #collection_Name# = arrayNew(1)>
</cfif>
<!--- Append the current attributes to the array --->
<cfset temp=arrayAppend(evaluate(collectionName), attributes)>
<cfparam Name='thisTag.assocAttribs' default=#arrayNew(1)#>
<!--- Loop over the attribute sets of all sub tags --->
<cfloop index=i from=1
to=#arrayLen(thisTag.assocAttribs)#>
<!--- Get the attributes structure --->
<cfset subAttribs = thisTag.assocAttribs[i]>
<!--- Perform other operations --->
</CFLOOP>
GetBaseTagList()
names. An empty string is returned if this is a top-level tag. The first element of a
non-empty list is the parent tag.
GetBaseTagData(TagName
all the variables (not just the local variables) of the nth ancestor with a given
attribute is the name of the structure in which the
attribute if the base tag can have more than one type of
Returns a comma-delimited list of uppercase ancestor tag
,
InstanceNumber=1)
Chapter 10 Reusing Code
Returns an object that contains
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers