application.cfc - Where to store common functions in ColdFusion -


We are running ColdFusion MX 7.

We have a problem that we have a lot of work we use in many pages

Is there a way to do this that does not include custom tags or preferences is? ?

I know that we can add applications or server scope to some objects, but then we have to give them context in this way.

Just be sure to add them to the global realm.

Edit

Thanks for the suggestions, here it is that I came along. In fact, for each request in the OnRequestStart function, assign the variable named in the function reference (this.functionName) client scope correctly.

Application.cfc:

& lt; Cfcomponent OUTPUT = "FALSE" & gt; & Lt; Cfset this.name = "MyApp" & gt; & Lt; CFSET This.clientManagement = true> & Lt; CFSET This.Session Management = True & gt; & Lt; CFFUNCTION NAME = "Coalesce" OUTPUT = "FALSE" Access = "Public" & gt; & Lt; Seafoodgroup name = "ARG1" & gt; & Lt; Seafragment name = "ARG2" & gt; & Lt; CFIF ARG1 NEQ "" & gt; & Lt; Seafront arg1 & gt; & Lt; CFELSE & gt; & Lt; Seafront ARG2 & gt; & Lt; / CFIF & gt; & Lt; / CFFUNCTION & gt; & Lt; Cffunction name = "onRequestStart" & gt; & Lt; CFSET CLIENT.COALESCE = this.COALESCE & gt; & Lt; / Cffunction & gt; & Lt; / Cfcomponent & gt;

The pages under this application happily respond to calls:

  & lt; CFOUTPUT & gt; #COALESCE ("ONE", "TWO") # & lt; / CFOUTPUT & gt;  

Works great!

There is no such thing as "global scope".

If you are talking about the scope of the variable in each page, you can try to include the application.cfm inside the UDF.

If you use application.cfc, then see again () in CF7 Doctor.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -