Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 190

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
<cfif #form.conversionType# is "CtoF">
<cfinvoke component="convertTemp" method="ctof" returnvariable="newtemp"
temp=#form.temperature#>
<cfoutput>#form.temperature# degrees Celsius is #newtemp# degrees
Farenheit.</cfoutput>
<cfelseif #form.conversionType# is "FtoC">
<cfinvoke component="convertTemp" method="ftoc"
returnvariable="newtemp" temp=#form.temperature#>
<cfoutput>#form.temperature# degrees Fahrenheit is #newtemp# degrees
Celsius.</cfoutput>
</cfif>
Reviewing the code
The file processForm.cfm invokes the appropriate component method. The following table describes the code and its
function:
Code
<cfif form.conversionType is "CtoF">
<cfinvoke component="convertTemp"
method="ctof"returnvariable="newtemp"arguments
.temp="#form.temperature#">
<cfoutput>#form.temperature# degrees Celsius is
b
#newtemp#
degrees Fahrenheit.</cfoutput>
<cfelseif #form.conversionType# is "FtoC">
<cfinvoke component="converttemp"
method="ftoc"returnvariable="newtemp"
temp=#form.temperature#>
<cfoutput>#form.temperature# degrees Fahrenheit
is #newtemp#degrees Celsius.</cfoutput>
</cfif>
To run the example, display the tempConversion.cfm page in your browser. When you enter a value in the text box of
the form, the value is stored in the
page, which refers to the value as
value
to
form.temperature
The appropriate method in the
value as
.
newtemp
For detailed reference information on the
Description
Executes the code in the cfif block if the user selected Celsius to Fahrenheit
as the conversion type in the form on the tempConversion.cfm page.
Invokes the
creating an instance of the
as the result variable for the method. Assigns the temperature value that the
user entered in the form to the variable
cfargument
the
temp
about variables and scope, see
Displays the temperature that the user entered in the form, the text
"degrees Celsius is," the new temperature value that results from the
method, and the text "degrees Fahrenheit."
Executes the code in the cfelseif block if the user selected Fahrenheit to
Celsius as the conversion type in the form on the tempConversion.cfm page.
Invokes the
creating an instance of the
as the result variable for the method. Assigns the temperature value that the
user entered in the form to the variable
cfargument
the
temp
about variables and scope, see
Displays the temperature that the user entered in the form, the text
"degrees Fahrenheit is," the new temperature value that results from the
ftoc
Closes the
variable. Processing is then performed on the processForm.cfm
form.temperature
. When you invoke either method, the cfinvoke tag assigns the
form.temperature
;
is the argument specified in the
temp
temp
component performs the necessary calculations and returns the new
convertTemp
tag, see the CFML Reference.
cfargument
Last updated 1/20/2012
ctof
method of the
convertTemp
convertTemp
temp
tag of the
ctof
method. When invoking the
variable is assigned to the Arguments scope. For more information
"CFC variables and
method of the
ftoc
convertTemp
convertTemp
temp
tag of the
ftoc
method. When invoking the
variable is assigned to the Arguments scope. For more information
"CFC variables and
method, and the text "degrees Celsius."
cfif
block.
tag of the appropriate method.
cfargument
component, without
component. Specifies
newtemp
, which is specified in the
ctof
method,
scope" on page 198.
ctof
component, without
component. Specifies
newtemp
, which is specified in the
ftoc
method,
scope" on page 198.
185

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents