| Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components |
|
|
|
|
||
You use the cfcomponent and cffunction tags to create ColdFusion components. By itself, the cfcomponent tag does not provide functionality. Rather, the cfcomponent tag provides an envelope that describes the functionality that you build in CFML and enclose in cffunction tags.
The following example creates a component with two methods:
<cfcomponent>
<cffunction name="getEmp">
<cfquery name="empQuery" datasource="ExampleApps" dbtype="ODBC" >
SELECT FIRSTNAME, LASTNAME, EMAIL
FROM tblEmployees
</cfquery>
<cfreturn empQuery>
</cffunction>
<cffunction name="getDept">
<cfquery name="deptQuery" datasource="ExampleApps" dbtype="ODBC" >
SELECT *
FROM tblDepartments
</cfquery>
<cfreturn deptQuery>
</cffunction>
</cfcomponent>
In the example, two cffunction tags define two component methods, getEmp and getDept. When invoked, the component methods query the ExampleApps database. The cfreturn tag returns the query results to the client.
The following sections discuss how you define components and their methods.
|
|
||
| Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components |
|
|
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.
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/buildi35.htm
Comments
Kwin said on Aug 15, 2003 at 1:37 AM : jrunrandy said on Mar 2, 2004 at 6:06 AM : Adam Cameron said on Oct 30, 2004 at 3:14 PM : No screen name said on Feb 28, 2005 at 8:17 AM : davenny22 said on Mar 15, 2005 at 1:56 AM :