Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Defining component methods PreviousNext

Defining component methods

You define component methods using cffunction tags, as the following example shows, which defines a getEmp method:

<cffunction name="getEmp" displayname="Get Employee" access="remote">
    <cfquery name="empQuery" datasource="ExampleApps" dbtype="ODBC" >
       SELECT FIRSTNAME, LASTNAME, EMAIL
       FROM tblEmployees
    </cfquery>
    <cfreturn empQuery>
</cffunction>

Because component methods are ColdFusion functions, most of their features and coding techniques are identical to those of user defined functions. For more information on using the cffunction tag to create functions, see Writing and Calling User-Defined Functions.

Tip: To improve performance, avoid using the cfparam tag in CFC methods. Instead, use the cfset tag or CFScript assignment statements.

The following cffunction tag attributes are used only for CFCs:

For detailed reference information on the cffunction tag, see CFML Reference.


Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Defining component methods 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.