View comments | RSS feed

Creating ColdFusion components

When you create CFCs, you create methods, which are ColdFusion user-defined functions, in the component page. You pass data to a method by using parameters. The method then performs the function and, if specified in the cfreturn tag, returns data.

You can also define variables in a CFC. Within a CFC, these variables are known as properties.

The following sections describe how to create CFCs:

Tags for creating CFCs

The following table lists the tags that you use to create a CFC. You use these tags on the CFML page that defines the CFC.

Tag Description

cfcomponent

Contains a component definition; includes attributes for introspection. For more information, see Building ColdFusion components.

cffunction

Defines a component method (function); includes attributes for introspection. For more information, see Defining component methods.

cfargument

Defines a parameter (argument) to a method; includes attributes for introspection. For more information, see Defining and using method parameters.

cfproperty

Defines variables for CFCs that provide web services; also use to document component properties. For more information, see The cfproperty tag.

Elements of a CFC

A CFC has the following characteristics:

Building ColdFusion components

You use the cfcomponent and cffunction tags to create ColdFusion components. By itself, the cffunction tag does not provide functionality. The cfcomponent tag provides an envelope that describes the functionality that you build in CFML and enclose in cffunction tags. The following example shows the skeleton of a component with two methods:

<cfcomponent>
   <cffunction name="firstMethod">
       <!--- CFML code for this method goes here. --->
   </cffunction>
   <cffunction name="secondMethod">
       <!--- CFML code for this method goes here. --->
   </cffunction>
</cfcomponent>

This section describes the following topics:


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

Version 7

Comments


No screen name said on Apr 27, 2007 at 11:32 AM :
The statement:

... This code executes when the CFC is instantiated or whenever you invoke a method of the CFC.

Is not correct. The code outside of the cffunction blocks only executes when you instantiate the CFC. So just calling a method does not execute this code.

 

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

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00001026.htm