1 Reply Latest reply on Jun 8, 2009 8:05 AM by mack_

    Function references and stateful cfcs?

    Jim-sama

      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