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.
Содержание 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...