View comments | RSS feed
Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Using ColdFusion components > Instantiating CFCs PreviousNext

Instantiating CFCs

If you use a CFC multiple times in a ColdFusion request, or if you use a CFC with persistent properties, use the cfobject tag or CreateObject function to instantiate the CFC before you call its methods.

The following example uses the cfobject tag to create an instance of the tellTime CFC.

<cfobject component="tellTime" name="tellTimeComp">

The following example uses the cfobject tag to instantiate the same component in CFScript:

tellTimeComp = CreateObject("component", "tellTime");

Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Using ColdFusion components > Instantiating CFCs PreviousNext

ColdFusion 9 | 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.

Comments


No screen name said on Sep 24, 2003 at 1:11 PM :
'The following example uses the cfobject tag to instantiate the same component in CFScript:'

should read:

'The following example uses the CreateObject function to instantiate the same component in CFScript:'
enderw88 said on Mar 25, 2004 at 6:58 AM :
Often times when instantiating a persistent CFC you will want to parameterize the creation. The accepted way to do this is to include in your CFC an initialization function and create the objec like this:

newObject = CreateObject("component", "com.yourCFC").init(your parameters);

And have the init function return "this"

 

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

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