Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Providing results Returning a results variable PreviousNext

Returning a results variable

In the component method definition, you use the cfreturn tag to return the results to the client as variable data. For example, the following getLocalTime2 component method returns the local time as a variable to the ColdFusion page or other client that invokes the method:

<cfcomponent>
   <cffunction name="getLocalTime">
      <cfreturn TimeFormat(now())>
   </cffunction>
</cfcomponent>

The ColdFusion page or other client, such as a Flash application, that receives the result then uses the variable data as appropriate.

Note: If a CFC is invoked using a URL or by submitting a form, ColdFusion MX returns the variable as a WDDX packet. ColdFusion MX cannot return methods to Flash. Therefore, a CFC that is invoked by Flash Remoting MX must not return the This scope.

You can return values of all data types, including strings, integers, arrays, and structures. The cfreturn tag returns a single variable, as does the return CFScript statement. Therefore, if you want to return more than one result value at a time, populate a structure with name-value pairs and return the structure using the cfreturn tag.

For more information on using the cfreturn tag, see CFML Reference.


Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Providing results Returning a results variable 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.