View comments | RSS feed

About ColdFusion components

A ColdFusion component (CFC) is a file saved with the extension .cfc. A CFC can contain data and functions. Within a CFC, data is referred to as properties. Although you use the cffunction tag to define functions within a CFC, they are typically referred to as methods instead of functions.

The page on which you define a CFC is also known as a component page. Component pages use the same tags and functions that regular CFML pages do, plus a small number of special tags (in particular, the cfcomponent tag) and tag attributes.

You define related methods in a CFC. Unlike ColdFusion custom tags, a single CFC can perform many related actions, defined in multiple methods. The methods may share a data context, such as metadata and scoping, or manage a particular database or set of tables. For example, you can define the methods to insert, update, delete, and retrieve records from a particular database or table in one CFC.

This section describes the following topics:


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

Version 7

Comments


Phillip Senn said on Jun 16, 2006 at 8:15 PM :
xxx.cfm contains:
<cfset xxxObj = CreateObject("Component","Components.xxx").Init("myDataSourceName")>
<cfset xxxQry = xxxObj.View1()>
<cfdump var="#xxxQry#">

xxx.cfc contains:
<cfcomponent displayname="xxx" output="False">
<cffunction name="Init" output="true" returntype="components.xxx">
<cfargument name="DSN" required="yes">
<cfset Variables.DSN = arguments.DSN>
<cfreturn this>
</cffunction>

<cffunction name="View1" output="False" returntype="query" hint="I return everything from xxx">
<cfset var rst = "">
<cfquery datasource="#Variables.DSN#" name="rst">
SELECT * FROM xxx
</cfquery>
<cfreturn rst>
</cffunction>
</cfcomponent>

 

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/00001023.htm