Sorry for the sentence phrase. I could not find a better way to describe this. But my problem is this:
I have 3 cfc, namely settings.cfc, prices.cfc and helpers.cfc. These cfcs extend the 4th cfc.cfc controller. Helper.cfc is as follows:
<cfcomponent extends="Controller"> <cffunction name="formatCurrency"> <cfset formattedCurrency = 1 /> <cfreturn formattedCurrency> </cffunction> <cffunction name="processTemplateVariables"> <cfargument name="templateText" default="defaultText" > <cfset formatCurrency() /> <cfreturn formattedCurrency > </cffunction> </cfcomponent>
The settings.cfc parameter has a setApplicationVariables method, which we use to set application-level variables. In this cfc, I created the helpers.cfc object and placed this object in the application area. The settings.cfc parameters are as follows:
<cfcomponent extends="Controller"> <cffunction name="setApplicationVariables"> <cfset application.helpers = createObject("component","controllers.Helpers") /> </cffunction> </cfcomponent>
The settings.cfc parameter is set when the application starts, which, in turn, creates the helpers.cfc object and places it in the application area. We create a reference to the ProcessTemplateVariables method in the .cfc controller as follows:
<cfcomponent extends="Wheels"> <cfset getFormattedCurrency = application.helpers.processTemplateVariables > </cfcomponent>
In price.cfc, we use this link to call the function processTemplateVariables that it does. But it does not call the function formatCurrency , which is called internally from processTemplateVariables and throws an error " formatCurrency variable - undefined ".
But if I use application.helpers.processTemplateVariables(templateText="someText") , it works.
It also works when I use cfinvoke as below:
<cfinvoke method="processTemplateVariables" component="controllers.helpers" templateText="someText" returnvariable="content">
.Cfc prices are as follows:
<cfcomponent extends="Controller"> <cffunction name="index"> <cfdump var="#getFormattedCurrency("someText")#"><cfabort> <cfinvoke method="processTemplateVariables" component="controllers.helpers" templateText="someText" returnvariable="content"> <cfset application.helpers.processTemplateVariables("someText") /> </cffunction> </cfcomponent>
I am not sure why using the link does not work. Sorry for the earlier confusion, but your comments made me dig deeper, and I could find out that it was a link that was the culprit. Is there any way to make this work a reference, would that be cool?