Adobe COLDFUSION 9 Manual page 132

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
The ColdFusion Administrator Sever Settings > Caching page now has a Component Cache option, and a Clear
Component Cache button. To prevent ColdFusion from caching resolved component paths, clear the Component
Cache option. Click the Clear Component Cache button to remove any resolved component paths from the cache.
Note: In all cases, ColdFusion automatically imports the com.adobe.coldfusion.* name space for CFCs. You do not have
to import this path explicitly.
The new operator creates an instance of a CFC. It is equivalent to the cfobject tags and CreateObject function. You can
use new as a CFScript operator, or in assignment statements outside a CFScript block, such as in a cfset tag. ColdFusion
does not have a corresponding cfnew tag.
The new operation has the following syntax:
cfObject=new cfcPath(constructorParam1,...)
or
cfObject=new cfcPath(arg1=constructorParam1Value,...)
If the folder name or CFC name has hyphen, use the following syntax:
cfObject=new "cfc-path"(constructorParam1,...)
If you use the import operator to import the directory that contains the CFC, the cfcPath value is the CFC filename.
The constructor parameters can be positional or in name="value" format. When you use the new operator, ColdFusion
does the following:
1
Looks for an initmethod constructor method in the CFC. If found, ColdFusion instantiates the component and
runs initmethod.
2
If it does not find an initmethod constructor method, it looks for an init constructor method. If found, ColdFusion
instantiates the component and runs initmethod.
If neither method exists, the new operation instantiates the component but does not call a constructor.
3
Note: Only the new operator automatically invokes the
value returned by
or
init
initmethod
and the
function do not invoke the function and you must explicitly call any custom initialization code.
CreateObject
Handling exceptions
ColdFusion provides two statements for exception handling in CFScript:
equivalent to the CFML
cftry
Note: For a discussion of exception handling in ColdFusion, see
Exception handling syntax and rules
Exception-handling code in CFScript has the following format:
initmethod
and if the return is void it returns the instance of the CFC. The
and
tags.
cfcatch
Last updated 8/5/2010
or
function. The new operator returns the
init
and
. These statements are
try
catch
"Handling
Errors" on page 275.
127
tags
cfobject

Advertisement

Table of Contents
loading

Table of Contents