Where to store common features in ColdFusion

We are launching ColdFusion MX7.

One of the problems is that we have many features that we use on many of our pages. It would be nice if they lived in the global ColdFusion area, rather than including them in all of our pages.

Is there a way to do this that doesn't include custom tags or the like?

I know that we could attach some objects to areas of applications or servers, but then we should refer to them as such.

Just adding them to a global area would be ideal.

EDIT

Thanks to the suggestions, this is what I came up with. In principle, for each request in the OnRequestStart function, assign a correctly named variable in the client area a function reference (this.functionName).

Application.cfc:

<cfcomponent OUTPUT="FALSE">
<cfset This.name = "MyApp">
<CFSET This.clientManagement = true>
<CFSET This.SessionManagement = true>

<CFFUNCTION NAME="Coalesce" OUTPUT="FALSE" access="public">
    <CFARGUMENT NAME="ARG1">
    <CFARGUMENT NAME="ARG2">

    <CFIF ARG1 NEQ "">
        <CFRETURN ARG1>
    <CFELSE>
        <CFRETURN ARG2>
    </CFIF>
</CFFUNCTION>

<cffunction name="onRequestStart">
    <CFSET CLIENT.COALESCE = this.COALESCE>
</cffunction>

</cfcomponent>

, , :

<CFOUTPUT>#COALESCE("ONE","TWO")#</CFOUTPUT>

!

+3
3

, " ".

, UDF Application.cfm.

Application.cfc, onRequest() CF7.

+6

, , ( ) Application.cfc. , . , , . , , application.services.myUsefulFunction()

+2

Check this box. He did a great job with me ...

How to organize small reuse features

+2
source

Source: https://habr.com/ru/post/1711298/


All Articles