cfobject: component object

Description

The cfobject tag can create a ColdFusion component (CFC) object.

Syntax

<cfobject 
  name = "variable name"
  component = "component name"> 

See also

cfcollection, cfcomponent, cfexecute, cfindex, cfreport, cfsearch, cfwddx

Attributes

Attribute Req/Opt Default Description
name
Required
 
String; name for the instantiated component. The name must not have a period as the first or last character.
component
Required
 
Name of component to instantiate

Usage

Executing operations on a CFC object executes CFML code that implements the CFC's method in the CFC file. Using this tag to instantiate a component returns a ComponentProxy object that can delegate control to a CFC page.

Example

<!--- separate instantiation and method invocation; permits multiple 
invocations --->
<cfobject 
name="quoteService" 
component="nasdaq.quote">
<cfinvoke 
component="#quoteService#" 
method="getLastTradePrice" 
symbol="macr" 
returnVariable="res">
<cfoutput>#res#</cfoutput><br>

<cfinvoke 
component="#quoteService#" 
method="getLastTradePrice" 
symbol="mot" 
returnVariable="res">
<cfoutput>#res#</cfoutput>

Comments