CFFUNCTION | |
Description
Defines functionality that you build in CFML. |
|
Category
Extensibility tags | |
Syntax<cffunction name = "methodName" returnType = "dataType" roles = "securityRoles" access = "methodAccess" output = "yes" or "no" > | |
See also
cfargument, cfcomponent, cfinvoke, cfinvokeargument, cfobject, cfproperty, cfreturn
|
|
Usage
Components that are stored in the same directory are members of a component package. Within a cffunction tag, if you specify the roles attribute, the method executes only if a user is logged in and belongs to one of the specified roles. For more information, see the "Building and Using ColdFusion Components" chapter in Developing ColdFusion MX Applications with CFML. The following example shows a typical use of this tag: <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."> |
|
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> |
NAME | |
Required | |
A string; a component method that is used within the cfcomponent tag. |
RETURNTYPE | |
Required for a web service; Optional, otherwise. | |
Default value: " any"
String; a type name; data type of the function return value.
If the value is not a recognized type, ColdFusion processes it as a component name. |
ROLES | |
Optional | |
Default value: """ (empty)"
This attribute is used only for a component. A comma-delimited list of ColdFusion security roles that can invoke the method. If this attribute is omitted, all roles can invoke the method. |
ACCESS | |
Optional | |
Default value: "public"
This attribute is used only for a component. The client security context from which the method can be invoked:
|
OUTPUT | |
Optional | |
Default value: "Function is processed as standard CFML"
This attribute is used only for a component.
|