In ColdFusion pages or components, the cfinvoke
tag can invoke component methods without creating a persistent CFC instance.
To invoke a component method transiently, use the cfinvoke
tag and specify the following:
component
attribute.
method
attribute.
returnVariable
attribute.
<cfcomponent> <cffunction name="getLocalTime"> <cfoutput>#TimeFormat(now())#</cfoutput> </cffunction> </cfcomponent>
The example defines a component with one method, getLocalTime
, that displays the current time.
<h3>Time Display Page</h3> <b>Server's Local Time:</b> <cfinvoke component="tellTime" method="getLocalTime">
Using the cfinvoke
tag, the example invokes the getLocalTime
component method without creating a persistent CFC instance.