224
Chapter 11: Building and Using ColdFusion Components
You can create persistent CFCs by assigning the CFC instance to a persistent scope, such as the
Session or Application scope. This way, you can create CFCs for objects, such as shopping carts or
logged-in users, that must persist for sessions. You can also create CFCs that provide application-
specific data and methods.
ColdFusion provides many ways to instantiate CFCs and invoke CFC methods. For detailed
information, see
“Using ColdFusion components” on page 224
.
Using ColdFusion components
This section includes the following information about using component methods:
•
Describes how ColdFusion finds CFCs and how to specify a CFC location
•
Describes how create CFC instances and invoke CFC methods from within ColdFusion MX
•
Briefly discusses invoking CFC methods from outside ColdFusion
•
Discusses how to use ColdFusion MX and Macromedia Dreamweaver MX tools to learn about
the CFCs on a server
Specifying the CFC location
When you instantiate or invoke a component, you can specify the component name only, or you
can specify a
qualified
path. To specify a qualified path, separate the directory names with periods,
not slashes; for example, myApp.cfcs.myComponent specifies the component defined in
myApp\cfcs\myComponent.cfc.
ColdFusion uses the following rules to find the specified CFC.
•
If you use a
cfinvoke
or
cfobject
tag, or the
CreateObject
function to access the CFC from
a CFML page, ColdFusion searches directories in the following order:
a
Local directory of the calling CFML page
b
Directories specified on the ColdFusion Mappings page of the ColdFusion MX
Administrator
c
Web root
d
Directories specified on Custom Tag Paths page of the Administrator
If you specify only a component name, ColdFusion searches each of these directories, in turn,
for the component.
Note:
If you use only the component name to specify the CFC, ColdFusion does not search the
directories specified in the Administrator on the ColdFusion Mappings page. If you specify a
qualified path that starts with a mapped directory name, ColdFusion does find the component.
If you specify a qualified path, such as myApp.cfcs.myComponent, ColdFusion looks for a
directory matching the first element of the path in each of these directories (in this example,
myApp). If it finds a matching directory, it then looks for a file in the specified path beneath
that directory, such as myApp\cfcs\myComponent.cfc relative to each of these directories.
Note:
If ColdFusion finds a directory that matches the first path element, but does not find a CFC
under that directory, ColdFusion returns a not found error and does
not
search for another
directory.
Summary of Contents for ColdFusion MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......