Providing Results - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

In the example, the
The
attributes define the parameter names
name
The
attribute for the lastName argument specifies that the parameter must be a text
type
string. The
type
numeric value. These attributes validate the data before it is submitted to the database.
The
required
thrown.
The Arguments variable scope provides access to the parameter values.

Providing results

ColdFusion components can provide information in the following ways:
They can generate output that is displayed on the calling page.
They can return a variable.
You can use either technique, or a combination of both in your applications. Which technique
you use should depend 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
getLocalTime1
invokes the method:
<cfcomponent>
<cffunction name="getLocalTime1">
<cfoutput>#TimeFormat(now())#</cfoutput>
</cffunction>
</cfcomponent>
Component methods that are called 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
as variable data. For example, the following
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.
attributes specify the following:
cfargument
attribute for the cost argument specifies that the parameter must be a
attributes indicate that the parameters are required or an exception will be
component method shows the local time directly on the page that
tag to return the results to the client
cfreturn
component method returns the local
getLocalTime2
Building ColdFusion components
239

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents