> Cool. Though it is probably worth noting the
callback_function has to be in
> the same context (ie page or cfc).
I'm not sure I follow.
<!--- c1.cfc --->
<cfcomponent>
<cffunction name="f">
<cfreturn "This is F">
</cffunction>
</cfcomponent>
<!--- c2.cfc --->
<cfcomponent>
<cffunction name="g">
<cfargument name="func" type="any">
<cfreturn arguments.func()>
</cffunction>
</cfcomponent>
<!--- caller.cfm --->
<cfset copyF = createObject("component", "c1").f>
<cfset o = createObject("component", "c2")>
<cfoutput>#o.g(copyF)#</cfoutput>
This grabs the f() function out of c1, passes it to g() in
c2, where it's
executed.
A function (UDF or CFC method) is pretty much just a variable
in CF, and
can be passed around as such.
You *would* have a problem if f() referred to other methods
or variables
within c1.cfc, because by the time you're running it, it's
not the method
that is the member of an instance of C1; it's just "some ol'
function". So
anything it *references* must be available in whichever scope
it ends up
being.
--
Adam