Whatever message this page gives is out now! Go check it out!
<cfcomponent>
<cffunction name="firstMethod">
<!--- CFML code for this method goes here. --->
</cffunction>
<cffunction name="secondMethod">
<!--- CFML code for this method goes here. --->
</cffunction>
</cfcomponent><cfcomponent>
<cffunction name="getall" output="false" returntype="query">
<cfset var queryall="">
<cfquery name="queryall" datasource="cfdocexamples">
SELECT * FROM EMPLOYEE
</cfquery>
<cfreturn queryall>
</cffunction>
<cffunction name="getsalary" output="false">
<cfset var getNamesandSalary="">
<cfquery name="getNamesandSalary" datasource="cfdocexamples">
SELECT FirstName, LastName, Salary FROM EMPLOYEE
</cfquery>
<cfreturn getNamesandSalary>
</cffunction>
</cfcomponent><cfcomponent>
<cffunction name="getEmp">
<cfset var empQuery="">
<cfquery name="empQuery" datasource="cfdocexamples" dbtype="ODBC">
SELECT FIRSTNAME, LASTNAME, EMAIL
FROM tblEmployees
</cfquery>
<cfreturn empQuery>
</cffunction>
<cffunction name="getDept">
<cfset var deptQuery="">
<cfquery name="deptQuery" datasource="cfdocexamples" dbtype="ODBC">
SELECT *
FROM tblDepartments
</cfquery>
<cfreturn deptQuery>
</cffunction>
</cfcomponent><cfcomponent>
<cffunction name="getUTCTime">
<cfinclude template="getUTCTime.cfm">
<cfreturn utcStruct.Hour & ":" & utcStruct.Minute>
</cffunction>
</cfcomponent><cfscript>
serverTime=now();
utcTime=GetTimeZoneInfo();
utcStruct=structNew();
utcStruct.Hour=DatePart("h", serverTime);
utcStruct.Minute=DatePart("n", serverTime);
utcStruct.Hour=utcStruct.Hour + utcTime.utcHourOffSet;
utcStruct.Minute=utcStruct.Minute + utcTime.utcMinuteOffSet;
if (utcStruct.Minute LT 10) utcStruct.Minute = "0" & utcStruct.Minute;
</cfscript><cfcomponent>
<!--- Initialize the array for the cart item IDs and quantities. --->
<cfset This.CartData = ArrayNew(2)>
<!--- The following variable has the ID of the "Special Deal" product for
this session. --->
<cfset This.Special_ID = RandRange(1, 999)><cfcomponent displayname="shoppingCart">
<cffunction name="init" access="public" output="no" returntype="shoppingCart">
<cfargument name="shoppingCartID" type="UUID" required="yes">
<cfset variables.shoppingCartID = arguments.shoppingCartID>
<cfreturn this>
</cffunction>
<!--- Additional methods go here. --->
</cfcomponent><cfcomponent>
<!--- Celsius to Fahrenheit conversion method. --->
<cffunction name="ctof" output="false">
<cfargument name="temp" required="yes" type="numeric">
<cfreturn ((temp*9)/5)+32>
</cffunction>
<!--- Fahrenheit to Celsius conversion method. --->
<cffunction name="ftoc" output="false">
<cfargument name="temp" required="yes" type="numeric">
<cfreturn ((temp-32)*5/9)>
</cffunction>
</cfcomponent>Code | Description |
<cfcomponent> | Defines the component. |
<cffunction name="ctof" output="false"> | Defines the ctof method.Indicates that this method does not display output. |
<cfargument name="temp" required="yes" type="numeric"> | Creates the temp parameter of the ctof method. Indicates that it is required and that the expected value is numeric. |
<cfreturn ((temp*9)/5)+32> | Defines the value that the method returns. |
</cffunction> | Ends the method definition. |
<cffunction name="ftoc" output="false"> | Defines the ftoc method.Indicates that this method does not display output. |
<cfargument name="temp" required="yes" type="numeric"> | Creates the temp parameter of the ftoc method. Indicates that it is required and that the expected value is numeric. |
<cfreturn ((temp-32)*5/9)> | Defines the value that the method returns. |
</cffunction> | Ends the method definition. |
</cfcomponent> | Ends the component definition. |
<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><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>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. |
<cfoutput>#form.temperature# degrees Celsius is #newtemp#}}b{{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. |
<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. |
<cfcomponent>
<cffunction name="getEmp">
<cfargument name="lastName" type="string" required="true"
hint="Employee last name">
<cfset var empQuery="">
<cfquery name="empQuery" datasource="cfdocexamples">
SELECT LASTNAME, FIRSTNAME, EMAIL
FROM tblEmployees
WHERE LASTNAME LIKE '#Arguments.lastName#'
</cfquery>
<!--- Use cfdump for debugging purposes. --->
<cfdump var=#empQuery#>
</cffunction>
<cffunction name="getCat" hint="Get items below specified cost">
<cfargument name="cost" type="numeric" required="true">
<cfset var catQuery="">
<cfquery name="catQuery" datasource="cfdocexamples">
SELECT ItemName, ItemDescription, ItemCost
FROM tblItems
WHERE ItemCost <= #Arguments.cost#
</cfquery>
<!--- Use cfdump for debugging purposes. --->
<cfdump var=#catQuery#>
</cffunction>
</cfcomponent><cfcomponent>
<cffunction name="getLocalTime1">
<cfoutput>#TimeFormat(now())#</cfoutput>
</cffunction>
</cfcomponent><cfcomponent>
<cffunction name="getLocalTime">
<cfreturn TimeFormat(now())>
</cffunction>
</cfcomponent><cfcomponent name="makeForm" Author="Bean Lapin"><cfcomponent displayname="Math Functions" MetaType="Float"><cfobject component="mathCFC" name="MathFuncs">
<cfset MetaTypeInfo=GetMetadata(MathFuncs).MetaType>URL | Form | Flash Remoting | Web services | ColdFusion page | |
Current directory | N/A | Yes | N/A | N/A | Yes |
Web root | Yes | Yes | Yes | Yes | Yes |
ColdFusion mappings | No | No | No | No | Yes |
Custom tag roots | No | No | No | No | Yes |
catalog.product.price<cfscript>
obj = {
testFunc = function(value){
writeOutput("Function Definition inside an Object with parameter " & value);
}
};
obj.testFunc("Param");
</cfscript><cfscript>
obj = {
testFunc = function(value){
writeOutput("Function Definition inside an Object with parameter " & value);
}
};
funcName = 'testFunc';
obj.testFunc("Param");
writeOutput("<br>");
obj['testFunc']("Param");
writeOutput("<br>");
obj[funcName]("Param");
</cfscript>