Copy link to clipboard
Copied
Using 8.0.1
ok, i have a happy component (example4.cfc):
<cfcomponent output="false">
<cfscript>
variables.txt = "un-init";
</cfscript>
<cffunction name="Init" access="public" returntype="example4" output="false">
<cfscript>
variables.txt = "init";
</cfscript>
<cfreturn this />
</cffunction>
<cffunction name="remoteEcho" access="remote" returntype="string" ExtDirect="true" output="false">
<cfargument name="str" type="string" required="true" />
<cfreturn str & "[" & variables.txt & "]"/>
</cffunction>
</cfcomponent>
and I am trying to call a function reference like so:
<cfscript>
cfc = CreateObject('Component', 'Example4').Init();
method = cfc['RemoteEcho']; //<- try to create function reference
</cfscript>
<cfdump var="#cfc#">
<cfdump var="#method#">
<cfdump var="#cfc.remoteEcho('bobo')#"><!--- this works, naturally --->
<cfdump var="#method('bobo')#"><!--- failure here --->
The problem that I am running into is that it cannot find the variables.txt private member.
Element TXT is undefined in VARIABLES.
The direct call works fine, however the reference acts as if it's, i don't know, a regular UDF outside of a cfc?
Any help here, or will this just not work?
-Jim
Copy link to clipboard
Copied
As far as I know it will not work if you're accessing private
variables because I seem to remember that the function reference is
not tied to the cfc instance.
Mack