MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 203

Table of Contents

Advertisement

Passing Data Between Nested Custom Tags
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
2
3
To create the first custom tag page:
1
2
3
To create the second custom tag page:
1
2
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.
Create a new application page (the calling page) in ColdFusion Studio.
Modify the file so that it appears as follows:
Call cf_nestag1 which calls cf_nestag2<br>
<cf_nestag1>
<hr>
Call cf_nestag2 directly<br>
<cf_nestag2>
<hr>
Using a loop to call call cf_nestag2<br>
<cfloop index=i from=1 to=2>
<cf_nestag2>
</cfloop>
Save the page as nesttest.cfm.
Create a new application page (the calling page) in ColdFusion Studio.
Put the following single line in the file:
<cf_nestag2>
Save the page as nestag1.cfm.
Create a new application page (the calling page) in ColdFusion Studio.
Modify the file so that it appears as follows:
<cfif thisTag.executionmode is 'start'>
<!--- Get the tag context stack. The list will look something like
"CFIF,MYTAGNAME..." --->
<cfset ancestorlist = getbasetaglist()>
<!--- Output your own name. You are the second entry because
the first entry in the context stack is the cfif tag at
the top of this file --->
<cfoutput>
<p>I'm custom tag #ListGetAt(ancestorlist,2)#</p>
183

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents