3 Replies Latest reply on May 21, 2015 1:32 PM by WolfShade

    One CFFUNCTION calling another in same CFC - using "this" isn't working

    WolfShade Level 4

      Hello, all,

       

      I've got a CFC (let's call it test.cfc) that is supposed to handle a lot of  internal calls to other CFFUNCTIONs.

       

      I had read that using "this.functionName(args);" should work.

       

      However, for some reason it isn't.  I still have to use "components.compName().functionName(args);" for it to work.  Pseudo-code:

       

      <cffunction name="functionA" access="private" output="no" returntype="any">
          <cfquery name="getThese" datasource="#application.thisDSN#">
            SELECT * FROM tableA ORDER BY ID
          </cfquery>
          <cfreturn getThese />
      </cffunction>
      

      and

      <cffunction name="functionB" access="private" output="yes" returntype="void">
          <cfset tmp = this.functionA() /><cfoutput>#tmp#</cfoutput>
      </cffunction>
      

      This produces the error: Ensure that the name is correct and that the component or interface exists.

       

      But the following works just fine:

       

      <cffunction name="functionB" access="private" output="yes" returntype="void">
          <cfset tmp = components.test().functionA() /><cfoutput>#tmp#</cfoutput>
      </cffunction>
      

      Any suggestions as to why "new this.test().functionA();" doesn't work?

       

      V/r,

       

      ^_^