Returns result values from a component method. Contains an expression returned as result of the function.
An expression; the result of the function from which this tag is called.
<cfreturn expr>
cfargument,
cfcomponent,
cffunction,
cfinvoke,
cfinvokeargument,
cfobject,
cfproperty
New in ColdFusion MX: This tag is new.
Attribute | Req/Opt | Default | Description |
---|---|---|---|
expr |
Required |
|
Function result; value of any type |
This tag is equivalent to a return
statement within a cfscript
tag. It accepts one return variable argument. To return more than one value, populate a structure with name-value-pairs, and return the structure with this tag.
To access the result value from this tag, you use the variable scope that is the value of the cfinvoke
tag returnVariable
attribute.
You can code a maximum of one cfreturn
tag within a function.
For example code, see the Building and Using ColdFusion Components chapter of Developing ColdFusion MX Applications with CFML.
<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>