CFFUNCTION |
|
 |
Description
|
Defines a function that you can call in CFML. Required to defined ColdFusion component methods.
|
|
Category
|
Extensibility tags
|
|
Syntax<cffunction
name = "methodName"
returnType = "dataType"
roles = "securityRoles"
access = "methodAccess"
output = "yes" or "no"
displayName = "name"
Hint = "hint text">
|
|
See also
|
cfargument, cfcomponent, cfinvoke, cfinvokeargument, cfobject, cfproperty, cfreturn
|
|
|
Usage
|
The cffunction tag can define a function that you call in the same manner as a ColdFusion built in function.
|
To define a ColdFusion component (CFC) method, you must use a cffunction tag. For information on using the cffunction tag.
|
The following example shows cffunction tag attributes for a simple CFC method that returns a ColdFusion Query object.
<cffunction
name="getEmployees"
access="remote"
returnType="query"
hint="This query returns all records in the employee database. It can
drill-down or narrow the search, based on optional input parameters.">
|
For information on using the cffunction tag for ColdFusion components, see Chapter 11, "Building and Using ColdFusion Components," in Developing ColdFusion MX Applications.
|
If you specify a roles attribute, the function executes only if a user is logged in and belongs to one of the specified roles.
|
If you specify variableName for the returnType attribute, the function must return a string that is in ColdFusion variable name format; that is, the function must return a string that starts with a letter, underscore, or Unicode currency symbol, and consist of letters, numbers, and underscores (_), periods, and Unicode currency symbols, only. ColdFusion does not check whether the value corresponds to an existing ColdFusion variable.
|
|
Example<cfcomponent>
<cffunction name="getEmp">
<cfquery
name="empQuery" datasource="ExampleApps" >
SELECT FIRSTNAME, LASTNAME, EMAIL
FROM tblEmployees
</cfquery>
<cfreturn empQuery>
</cffunction>
<cffunction name="getDept">
<cfquery
name="deptQuery" datasource="ExampleApps" >
SELECT *
FROM tblDepartments
</cfquery>
<cfreturn deptQuery>
</cffunction>
</cfcomponent>
|