Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 189

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Code
<cfcomponent>
<cffunction name="ctof" output="false">
<cfargument name="temp" required="yes"
type="numeric">
<cfreturn ((temp*9)/5)+32>
</cffunction>
<cffunction name="ftoc" output="false">
<cfargument name="temp" required="yes"
type="numeric">
<cfreturn ((temp-32)*5/9)>
</cffunction>
</cfcomponent>
Example: tempConversion.cfm
The ColdFusion page tempConversion.cfm is an HTML form in which the user enters the temperature to convert, and
selects the type of conversion to perform. When the user clicks the Submit button, ColdFusion performs the actions
on the processForm.cfm page. The file tempConversion.cfm, which is in the same directory as convertTemp.cfc,
consists of the following:
<cfform action="processForm.cfm" method="POST">
Enter the temperature:
<input name="temperature" type="text"><br>
<br>
Select the type of conversion:<br>
<select name="conversionType">
<option value="CtoF">Celsius to Farenheit</option>
<option value="FtoC">Farenheit to Celsius</option>
</select><br><br>
<input name="submitform" type="submit" value="Submit">
</cfform>
Example: processForm.cfm
The ColdFusion page processForm.cfm calls the appropriate component method, based on what the user entered in
the form on the tempConversion.cfm page. Place it in the same directory as convertTemp.cfc.
Description
Defines the component.
Defines the
ctof
method.
Indicates that this method does not display output.
Creates the
parameter of the
temp
that the expected value is
numeric
Defines the value that the method returns.
Ends the method definition.
Defines the
ftoc
method.
Indicates that this method does not display output.
Creates the
temp
parameter of the
that the expected value is
numeric
Defines the value that the method returns.
Ends the method definition.
Ends the component definition.
Last updated 1/20/2012
method. Indicates that it is required and
ctof
.
ftoc
method. Indicates that it is required and
.
184

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents