Contents > CFML Reference > ColdFusion Functions > CreateObject: component object PreviousNext

CreateObject: component object

The CreateObject function can create an instance of a ColdFusion component (CFC) object.

A component object.

CreateObject(type, component-name) 

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

On UNIX systems, ColdFusion searches first for a file with a name that matches the specified component name, but is all lower case. If it does not find the file, it looks for a file name 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. For more information, see Building and Using ColdFusion Components in Developing ColdFusion MX Applications.

<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>

Contents > CFML Reference > ColdFusion Functions > CreateObject: component object PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi45.htm