Created a UDF world but don't know what to call it, please help

I created a cfproperty and a bunch of features inside.  One of the functions must rely on a process that must also by another part of the application. Since this 'process' is needed in different parts of the application, I decided to make this 'treatment' a global function that can be called from any part of the application. I found a blog of Ben Nadel which explained exactly what I need. But the problem is that I do not understand how to call the UDF globa, his explanation is not clear to me. Ben created UDF.cfc:

cfproperty output = "false" hint = "I define the parameters of the application and event handlers.

cffunction name = "getMessage" access = "public" returntype = "string" output = "false" hint = "I send a test message."

-Here's where I wrote the process required by the different parts of the application.

CFRETURN "I'm defined in the component of the UDF.
cffunction

cfproperty

On the Application.cfc, he created a URL field: cfproperty output = "false" hint = "I defined the parameters of the application and event handlers."

Set the application:


CFSET myIdName = hash (getCurrentTemplatePath())
CFSET this.applicationTimeout = createTimeSpan (0, 0, 0, 5)


Add all of our "global" methods to the scope of the URL. Since
ColdFusion will automatically search the URL field for
variables not limited in scope, it will find our open-ended scope method
names of:

CFSET structAppend (url, createObject ("component", "UDF"))

cfproperty

Is the part that I don't understand, how to call the getMessage method? Is: application.cfc.UDF.getMessage (parameter1, parameter2)?

Based on this code, you must refer to it as "URL. UDF.getMessage ().

Where the line "cfset structAppend (url, createObject ("component","UDF")) ' actually occur inside Application.cfc (above all definitions function or inside a function)?  It's at the top of the component definition, this UDF gets instantiated on each request and put in the URL of the page field.  The component of the UDF maintains state somehow?  If no, and you ensure that all its methods are thread-safe, I would just record it in the scope as follows:

Put this in your Application.cfc in onApplicationStart() method so that it is instantiated only once.  Then call its methods from anywhere in your application as "application. UDF.getMessage ().

-Carl V.

Tags: ColdFusion

Similar Questions

Maybe you are looking for