
151
DEVELOPING
COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Las
t
upda
te
d 8/5/2010
</cf_myTag>
For information on using the
cfmodule
and
cfimport
tags to call custom CFML tags, see “
Creating and Using
Custom CFML Tags
” on page 208.
Recommended uses
ColdFusion custom tags let you abstract complex code and programming logic into simple units. These tags let you
maintain a CFML-like design scheme for your code. You can easily distribute your custom tags and share tags with
others. For example, the ColdFusion Developer Exchange includes a library of custom tags that perform a wide variety
of often-complex jobs; see
www.adobe.com/go/learn_cfu_exchange_en
.
Consider using CFML custom tags in the following circumstances:
•
You need a tag-like structure, which has a body and an end tag, with the body contents changing from invocation
to invocation.
•
You want to associate specific processing with the beginning tag, the ending tag, or both tags.
•
To use a logical structure in which the tag body uses “child” tags or subtags. This structure is like the
cfform
tag,
which uses subtags for the individual form fields.
•
You do not need a function format in which the calling code uses a direct return value.
•
Your code must be recursive.
•
Your functionality is complex.
•
To distribute your code in a convenient form to others.
If you can create either a UDF or a custom CFML tag for a purpose, first consider creating a UDF because running it
requires less system overhead than using a custom tag.
For more information
For more information on custom CFML tags, see “
Creating and Using Custom CFML Tags
” on page 208.
Using CFX tags
ColdFusion Extension (CFX) tags are custom tags that you write in Java or C++. Generally, you create a CFX tag to do
something that is not possible in CFML. CFX tags also let you use existing Java or C++ code in your ColdFusion
application. Unlike CFML custom tags, CFX tags cannot have bodies or ending tags.
CFX tags can return information to the calling page in a page variable or by writing text to the calling page.
CFX tags can do the following:
•
Have any number of custom attributes.
•
Create and manipulate ColdFusion queries.
•
Dynamically generate HTML that your page returns to the client.
•
Set variables within the ColdFusion page from which they are called.
•
Throw exceptions that result in standard ColdFusion error messages.
Calling CFX tags
To use a CFX tag, precede the class name with cfx_ and place the name in angle brackets. For example, use the
following line to call the CFX tag defined by the MyCFXClass class and pass it one attribute.
<cfx_MyCFXClass myArgument="arg1">
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...