Whatever message this page gives is out now! Go check it out!
Tag | Description |
Invokes a method of a CFC. | |
Passes the name and value of a parameter to a component method. | |
Creates a CFC instance. | |
Creates a CFC instance. |
Invocation | Description | For more information |
cfinvoke tag | Invokes a component method. Can invoke methods of a CFC instance or invoke the methods transiently. | See Invoking CFC methods with the cfinvoke tag in this page. |
cfset tag and assignment statements | Invoke methods and access properties of a component instance. | See Using components directly in CFScript and CFML in this page. |
URL (HTTP GET) | Transiently invokes a component method by specifying the component and method names in the URL string. | See Invoking component methods by using a URL in this page. |
Form control(HTTP POST) | Transiently invokes a component method using the HTML form and input tags and their attributes. | See Invoking component methods by using a form in this page. |
Flash Remoting | ActionScript can transiently invoke component methods. | |
Web services | The cfinvoke tag and CFScript consume web services in ColdFusion. External applications can also consume CFC methods as web services. | See Using Web Services. |
<cfobject component="tellTime" name="tellTimeObj">tellTimeObj = CreateObject("component", "tellTime");<cfcomponent>
<cffunction name="getLocalTime" access="remote">
<cfreturn TimeFormat(now())>
</cffunction>
<cffunction name="getUTCTime" access="remote">
<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>
<cfreturn utcStruct.Hour & ":" & utcStruct.Minute>
</cffunction>
</cfcomponent><!--- Create the component instance. --->
<cfobject component="tellTime2" name="tellTimeObj">
<!--- Invoke the methods. --->
<cfinvoke component="#tellTimeObj#" method="getLocalTime" returnvariable="localTime">
<cfinvoke component="#tellTimeObj#" method="getUTCTime" returnvariable="UTCTime">
<!--- Display the results. --->
<h3>Time Display Page</h3>
<cfoutput>
Server's Local Time: #localTime#<br>
Calculated UTC Time: #UTCTime#
</cfoutput><cfcomponent>
<cffunction name="getLocalTime">
<cfoutput>#TimeFormat(now())#</cfoutput>
</cffunction>
</cfcomponent><h3>Time Display Page</h3>
<b>Server's Local Time:</b>
<cfinvoke component="tellTime" method="getLocalTime"><cfcomponent>
<cffunction name="servicemethod" access="public">
<cfoutput>At your service...<br></cfoutput>
</cffunction>
<cffunction name="mymethod" access="public">
<cfoutput>We're in mymethod.<br></cfoutput>
<!--- Invoke a method in this CFC. --->
<cfinvoke method="servicemethod">
</cffunction>
</cfcomponent><select name="whichreport">
<option value="all">Complete Report</option>
<option value="salary">Salary Information</option>
</select><cfinvoke component="getdata" method="#form.whichreport#" returnvariable="queryall"><!--- Instantiate once and reuse the instance.--->
<cfscript>
tellTimeObj=CreateObject("component","tellTime");
WriteOutput("Server's Local Time: " & tellTimeObj.getLocalTime());
WriteOutput("<br> Calculated UTC Time: " & tellTimeObj.getUTCTime());
</cfscript><cfobject name="tellTimeObj" component="tellTime">
<cfoutput>
Server's Local Time: #tellTimeObj.getLocalTime()#<br>
Calculated UTC Time: #tellTimeObj.getUTCTime()#
</cfoutput><cfobject name="userDataCFC" component="userData">
<cfif DateDiff("d", userDataCFC.lastUpdated, Now()) GT 30>
<!--- Code to deal with older data goes here. --->
</cfif>http://localhost:8500/tellTime.cfc?method=getLocalTimehttp://localhost:8500/corpQuery.cfc?method=getEmp&lastName=camdenhttp://localhost:8500/corpQuerySecure.cfc?method=getAuth&store=women&dept=shoes<form action="myComponent.cfc" method="POST">.
<input type="Hidden" name="method" value="myMethod"><form action="myComponent.cfc?method=myMethod" method="POST">.<h2>Find People</h2>
<form action="components/corpQuery.cfc?method=getEmp" method="post">
<p>Enter employee's last Name:</p>
<input type="Text" name="lastName">
<input type="Hidden" name="method" value="getEmp">
<input type="Submit" title="Submit Query"><br>
</form><cfcomponent>
<cffunction name="getEmp" access="remote">
<cfargument name="lastName" required="true">
<cfset var empQuery="">
<cfquery name="empQuery" datasource="cfdocexamples">
SELECT LASTNAME, FIRSTNAME, EMAIL
FROM tblEmployees
WHERE LASTNAME LIKE '#arguments.lastName#'
</cfquery>
<cfoutput>Results filtered by #arguments.lastName#:</cfoutput><br>
<cfdump var=#empQuery#>
</cffunction>
</cfcomponent>http://localhost/corpFind.cfmhttp://localhost:8500/MyComponents/arithCFC.cfc?wsdl