Adobe COLDFUSION 9 Manual page 227

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
<!--- Get base tag instance data --->
<cfset data = getBaseTagData(baseTag)>
<!--- 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)>
The code accessing subtag attributes in the base tag could look like the following:
<!--- Protect against no subtags --->
<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>
Ancestor data access
A structure object contains all the ancestor's data.
The following functions provide access to ancestral data:
: Returns a comma-delimited list of uppercase ancestor tag names, as a string. The first list
GetBaseTagList
element is the current tag, the next element is the parent tag name if the current tag is a nested tag. If the function
is called for a top-level tag, it returns an empty string.
,
GetBaseTagData
InstanceNumber=1)
variables) of the nth ancestor with a given name. By default, the closest ancestor is returned. If there is no ancestor
by the given name, or if the ancestor does not expose any data (such as
Example: ancestor data access
This example creates two custom tags and a simple page that calls each of the custom tags. The first custom tag calls
the second. The second tag reports on its status and provides information about its ancestors.
Create the calling page
Create a ColdFusion page (the calling page) with the following content:
1
Call cf_nesttag1 which calls cf_nesttag2<br>
<cf_nesttag1>
<hr>
Call cf_nesttag2 directly<br>
<cf_nesttag2>
<hr>
2
Save the page as nesttest.cfm.
: Returns an object that contains all the variables (not just the local
Last updated 8/5/2010
), an exception is thrown.
cfif
222

Advertisement

Table of Contents
loading

Table of Contents