Adobe COLDFUSION 9 Manual page 223

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Determining the tag execution mode
The variable
thisTag.ExecutionMode
the following values:
Mode for processing the end tag.
Start
Mode for processing the end tag.
End
Mode when the custom tag uses nested tags. For more information, see
Inactive
If an end tag is not explicitly provided, ColdFusion invokes the custom tag page only once, in Start mode.
A custom tag page named bold.cfm that makes text bold could be written as follows:
<cfif thisTag.ExecutionMode is 'start'>
<!--- Start tag processing --->
<B>
<cfelse>
<!--- End tag processing --->
</B>
</cfif>
You then use this tag to convert the text to bold:
<cf_bold>This is bold text</cf_bold>
You can also use
to determine the execution mode of a custom tag:
cfswitch
<cfswitch expression=#thisTag.ExecutionMode#>
<cfcase value= 'start'>
<!--- Start tag processing --->
</cfcase>
<cfcase value='end'>
<!--- End tag processing --->
</cfcase>
</cfswitch>
Considerations when using end tags
How you code your custom tag to divide processing between the start tag and end tag depends greatly on the function
of the tag. However, use the following rules to help you make your decisions:
• Use the start tag to validate input attributes, set default values, and validate the presence of the end tag if the custom
tag requires it.
• Use the end tag to perform the actual processing of the tag, including any body text passed to the tag between the
start and end tags. For more information on body text, see
• Perform output in either the start or end tag; do not divide it between the two tags.
Processing body text
Body text is any text that you include between the start and end tags when you call a custom tag, for example:
<cf_happybirthdayMessge name="Ellen Smith" birthDate="June, 8, 1993">
<p> Happy Birthday Ellen!</p>
<p> May you have many more!</p>
</cf_happybirthdayMessge>
In this example, the two lines of code after the start tag are the body text.
contains the mode of invocation of a custom tag page. The variable has one of
"Processing body
Last updated 8/5/2010
"Nesting custom
tags" on page 219.
text" on page 218.
218

Advertisement

Table of Contents
loading

Table of Contents