Adobe COLDFUSION 9 Manual page 194

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Saving and naming ColdFusion components
The following table lists the locations in which you can save component files and how they can be accessed from each
location:
Current directory
Web root
ColdFusion mappings
Custom tag roots
Note: ColdFusion mappings and custom tag roots can exist within the web root. If so, they are accessible to remote
requests, including URL, form, Flash Remoting, and web services invocation.
When you store components in the same directory, they are members of a component package. You can group related
CFCs into packages. Your application can refer to any component in a directory specifically by using a qualified
component name that starts with a subdirectory of one of the accessible directories and uses a period to delimit each
directory in the path to the directory that contains the component. For example, the following example is a qualified
name of a component named
catalog.product.price
In this example, the price.cfc file must be in the catalog\product subdirectory of a directory that ColdFusion searches
for components, as listed in the preceding table. When you refer to a component using the qualified name, ColdFusion
looks for the component in the order described in
Establishing a descriptive naming convention is a good practice, especially if you plan to install the components as part
of a packaged application.
Using ColdFusion components
You can use a CFC in two ways:
1
You can instantiate a CFC object, which creates a CFC instance. You then invoke the methods of the instance. You
can access the CFC methods and data as instance elements. You can also use the instance in the cfinvoke tag to
invoke the CFC methods. When you instantiate a CFC, data in the CFC is preserved as long as the CFC instance
exists, and ColdFusion does not incur the overhead of creating the instance each time you call a method.
Instantiate CFCs to preserve data in the CFC. To ensure processing efficiency if you use the CFC more than once
on a page, instantiate the CFC before you invoke its methods.
Methods that are executed remotely through Flash Remoting and web services always create an instance of the CFC
before executing the method.
You can invoke (call) a method of the CFC without creating an instance of the CFC, which is referred to as
2
transiently invoking a method. In this case, ColdFusion creates an instance of the CFC that exists only from the time
you invoke the method until the method returns a result. No data is preserved between invocations and ColdFusion
does not keep an instance of the CFC that you can reuse elsewhere in your CFML. It is considered a best practice
to create an instance of a CFC before invoking any of its methods, unless your CFML request uses the CFC only
once. If you transiently invoke a method frequently, consider creating a user-defined function to replace the CFC
method.
URL
Form
N/A
Yes
Yes
Yes
No
No
No
No
:
price
"Specifying the CFC
Last updated 8/5/2010
Flash Remoting
Web services
N/A
N/A
Yes
Yes
No
No
No
No
location" on page 196.
189
ColdFusion page
Yes
Yes
Yes
Yes

Advertisement

Table of Contents
loading

Table of Contents