|
CreateObject: component object
DescriptionThe CreateObject function
can create an instance of a ColdFusion component (CFC) object.
ReturnsA component
object.
Function syntaxCreateObject(type, component-name)
Parameters
Parameter
|
Description
|
type
|
Type of object to create.
com
corba
java
component
webservice
|
component-name
|
The CFC name; corresponds to the name of
the file that defines the component; for example, use engineComp
to specify the component defined in the engineComp.cfc file
|
UsageOn UNIX
systems, ColdFusion searches first for a file with a name that matches the
specified component name, but is all lowercase. If it does not find
the file, it looks for a filename that matches the component name
exactly, with the identical character casing.
In the following
example, the CFScript statements assign the tellTimeCFC variable
to the tellTime component using the CreateObject function.
The CreateObject function references the component
in another directory. To invoke component methods, you use function
syntax.
<b>Server's Local Time:</b>
<cfscript>
tellTimeCFC=CreateObject("component","appResources.components.
tellTime");
tellTimeCFC.getLocalTime();
</cfscript>
<br>
<b>Calculated UTC Time:</b>
<cfscript>
tellTimeCFC.getUTCTime();
</cfscript>
|