I created a cfcomponent and a bunch functions inside it. One of the function needs to call a process that is also needed by other part of the application. Since this "process" is needed in a different parts of the application, I decided to make this "process" a global function that can be called from any part of the application. I found a blog from Ben Nadel that explained exactly what I need. But the problem is I don't quite understand how to call the globa UDF, his explanation is not clear to me. Ben created UDF.cfc:
cfcomponent output="false" hint="I define the application settings and event handlers.
cffunction name="getMessage" access="public" returntype="string" output="false" hint="I return a test message."
-- Here is where I wrote the process needed by different parts of the application --
cfreturn "I am defined in the UDF component"
cffunction
cfcomponent
On the Application.cfc he created a URL scope: cfcomponent output="false" hint="I define the application settings and event handlers."
Define the application:
cfset this.name = hash( getCurrentTemplatePath() )
cfset this.applicationTimeout = createTimeSpan( 0, 0, 5, 0 )
Add all of our "global" methods to the URL scope. Since
ColdFusion will automatically seach the URL scope for
non-scoped variables, it will find our non-scoped method
names:
cfset structAppend(url,createObject( "component", "UDF" ))
cfcomponent
The part that I don't understand is, how to call getMessage method? Is it: application.cfc.UDF.getMessage(parameter1,parameter2) ??