Invoking component methods transiently using the cfinvoke tag

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:

To invoke a component method using the cfinvoke tag:

  1. Create the following component and save it as tellTime.cfc:
    <cfcomponent>
    	<cffunction name="getLocalTime">
    		<cfoutput>#TimeFormat(now())#</cfoutput>	
    	</cffunction>
    </cfcomponent>
    

    The example defines a component with one method, getLocalTime, that displays the current time.

  2. Create a ColdFusion page, with the following code, and save it in the same directory as the tellTime component:
    <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.


View comments in LiveDocs