Skip to main content
Inspiring
November 19, 2010
Question

Application.cfc question

  • November 19, 2010
  • 3 replies
  • 629 views

If I have an Application.cfc in the root of my app, and an Application.cfm in a folder off the root, does the root's application.cfc invalidate the Application.cfm in a sub folder?

Thanks

Mark

    This topic has been closed for replies.

    3 replies

    Community Expert
    November 19, 2010

    No, the Application.cfm in the subfolder will execute. CF will find that before it finds the parent Application.cfc.

    Dave Watts, CTO, Fig Leaf Software

    http://www.figleaf.com/

    http://training.figleaf.com/

    Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

    GSA Schedule, and provides the highest caliber vendor-authorized

    instruction at our training centers, online, or onsite.

    Read this before you post:

    http://forums.adobe.com/thread/607238

    Dave Watts, Eidolon LLC
    Inspiring
    November 19, 2010

    I believe the lower down the file structure, the more that application file has precedence.

    However, if in your root application you have an onRequestStart method defined, and in your lower (but higher precedence) application file you did not define an onRequestStart function, the lower application will inherit the functionality of the root application file and run it's onRequestStart.  If you wanted to stop this, just create an onRequestStart function in the lower application file that does nothing.

    ilssac
    Inspiring
    November 19, 2010

    Aegis Kleais wrote:

    However, if in your root application you have an onRequestStart method defined, and in your lower (but higher precedence) application file you did not define an onRequestStart function, the lower application will inherit the functionality of the root application file and run it's onRequestStart.  If you wanted to stop this, just create an onRequestStart function in the lower application file that does nothing.

    Not be default, it won't.  This behavior will only happen if you, the developer, explicitly extends the higher Application.cfc file in a lower level Application.cfc.

    This will not happen with a stand alone Application.cfc that does not have an 'extends' parameter, nor will it happen with an Application.cfm file.

    Participating Frequently
    November 19, 2010

    Having an Application.cfm file in a subfolder will mean that application.cfc

    will no longer be used for any files in that subfolder. Same for

    Application.cfc being in a subfolder.

    Basically you can have multiple CF applications in one site, based on those

    application files.

    Inspiring
    November 19, 2010

    I've can't say I've every tried it (which you could do yourself, very easily, answering your own question), but given the way Application.cfc/.cfm look-ups work, CF will stop looking for an upstream one (be it either) as soon as it finds the nearest one to the currently requested template, if that makes sense.

    So CF will never know there's an "upstream" Application.cfc, because it'll stop looking as soon as it finds the Application.cfm

    But why don't you knock together a quick test and confirm this?  It'd take about 5min, I should think...

    --
    Adam