Nesting custom tags
189
The code accessing sub-tag attributes in the base tag could look like the following:
<!--- Protect against no sub-tags --->
<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
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:
•
GetBaseTagList
()
Returns a comma-delimited list of uppercase ancestor tag names, as a
string. The first list 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
(TagName
,
InstanceNumber=1)
Returns an object that contains all the
variables (not just the local 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
cfif
), an exception is thrown.
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.
To create the calling page:
1
Create a ColdFusion page (the calling page) with the following content:
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.
To create the first custom tag page:
1
Create a ColdFusion page with the following content:
<cf_nesttag2>
2
Save the page as nesttag1.cfm.
Содержание COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...