User Guide

Table Of Contents
Creating ColdFusion components 211
Reviewing the code
The file processForm.cfm invokes the appropriate component method. The following table
describes the code and its function:
Code Description
<cfif form.conversionType is "CtoF">
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.
<cfinvoke component="convertTemp"
method="ctof"
returnvariable="newtemp"
arguments.temp="#form.temperature#"
>
Invokes the ctof method of the convertTemp
component, without creating an instance of the
convertTemp component. Specifies newtemp as the
result variable for the method. Assigns the
temperature value that the user entered in the form to
the variable
temp, which is specified in the cfargument
tag of the
ctof method. When invoking the ctof
method, the
temp variable is assigned to the
Arguments scope. For more information about
variables and scope, see “CFC variables and scope”
on page 227.
<cfoutput>#form.temperature# degrees
Celsius is #newtemp# degrees
Fahrenheit.</cfoutput>
Displays the temperature that the user entered in the
form, the text
"degrees Celsius is," the new
temperature value that results from the
ctof method,
and the text
"degrees Fahrenheit."
<cfelseif #form.conversionType# is
"FtoC">
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.
<cfinvoke component="converttemp"
method="ftoc"
returnvariable="newtemp"
temp=#form.temperature#>
Invokes the ftoc method of the convertTemp
component, without creating an instance of the
convertTemp component. Specifies newtemp as the
result variable for the method. Assigns the
temperature value that the user entered in the form to
the variable
temp, which is specified in the cfargument
tag of the
ftoc method. When invoking the ftoc
method, the
temp variable is assigned to the
Arguments scope. For more information about
variables and scope, see “CFC variables and scope”
on page 227
<cfoutput>#form.temperature# degrees
Fahrenheit is #newtemp# degrees
Celsius.</cfoutput>
Displays the temperature that the user entered in the
form, the text
"degrees Fahrenheit is," the new
temperature value that results from the
ftoc method,
and the text
"degrees Celsius."
</cfif>
Closes the cfif block.