Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 192

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
You can use either technique, or a combination of both, in your applications. The best technique to use depends on
your application's needs and your coding methodologies. For example, many CFC methods that perform business
logic return the results as a variable, and many CFC methods that display output directly are designed as modular units
for generating output, and do not do business logic.
Displaying output
If you do not specifically suppress output, any text, HTML code, or output that CFML tags generate inside your
method gets returned as generated output to the client that calls the component method. If the client is a web browser,
it displays these results. For example, the following
on the page that invokes the method:
<cfcomponent>
<cffunction name="getLocalTime1">
<cfoutput>#TimeFormat(now())#</cfoutput>
</cffunction>
</cfcomponent>
Component methods that are called by using Flash Remoting or as web services cannot use this method to provide
results.
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
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 returns the variable as a WDDX packet. A
CFC that is invoked by Flash Remoting, or any other instance of a CFC, must not return the This scope.
You can return values of all data types, including strings, integers, arrays, structures, and instances of CFCs. The
tag returns a single variable, as does the
cfreturn
than one result value at a time, use a structure. If you do not want to display output in a method, use
in the cffunction tag.
For more information on using the
Documenting CFCs
ColdFusion provides several ways to include documentation about your CFCs in your component definitions. The
documentation is available when you use introspection to display information about the CFC or call the
or GetComponentMetaData function to get the component's metadata. You can use the following tools for
documenting CFCs:
• The
and
displayname
hint
• User-defined metadata attributes
• The cfproperty tag
getLocalTime1
component method returns the local time as a variable to the ColdFusion page
CFScript statement. Therefore, if you want to return more
return
tag, see the CFML Reference.
cfreturn
attributes
Last updated 1/20/2012
component method shows the local time directly
187
"
"
output=
false
GetMetadata

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents