CreateObject: component object

Description

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

Return value

A component object.

Syntax

CreateObject(type, component-name)  

Parameters

Parameter Description
type
Type of object to create.
  • com
  • corba
  • java
  • component
  • webservice
component-name
name of a component method

Usage

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 Developing ColdFusion MX Applications with CFML.

Example

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

Comments