Highlighted

Which Application.cfc get executed?

Engaged ,
Jun 22, 2016

Copy link to clipboard

Copied

I'm working on a clients system that has a library of CFC's in a folder called /Admin/cfcs.   Inside that folder is an Application.cfc file.

There is also an Application.cfc file at the root directory.  Off the root directory are other folders in addition to the Admin folder.

When I execute the template /Members/Index.cfm a few of the methods from the CFC library get executed.

If there aren't any calls to the CFC library I'm 100% sure the Application.cfc in the root folder gets executed when I run any of the templates in any folder off  the  root folder.

My question is if a template, such as /Members/Index.cfm, invokes a method from the CFC library does the Application.cfc template in the /Admin/cfcs folder get executed or is the root Application.cfc the one executed.

I believe it's just the root one but I'm not 100% sure. 

Any thoughts???  Does having an Application.cfc in the library folder cause any issues???

Thanks in advance for the assist!

Your assumption is correct.  The application.cfc in /Admin/cfc is not being executed, at all, unless there is a .cfm file that is being somehow utilized.  The CF Server first searches the current .cfm document folder for application.cfc/cfm; if it doesn't find it, it keeps recursively searching lower and lower folders until it finds an application.cfc/cfm and executes it.  CFCs in a folder with an application.cfc/cfm do not execute another application.cfc/cfm; they rely on the one that was already executed before loading the requested .cfm file.

HTH,

^_^

Views

272

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Which Application.cfc get executed?

Engaged ,
Jun 22, 2016

Copy link to clipboard

Copied

I'm working on a clients system that has a library of CFC's in a folder called /Admin/cfcs.   Inside that folder is an Application.cfc file.

There is also an Application.cfc file at the root directory.  Off the root directory are other folders in addition to the Admin folder.

When I execute the template /Members/Index.cfm a few of the methods from the CFC library get executed.

If there aren't any calls to the CFC library I'm 100% sure the Application.cfc in the root folder gets executed when I run any of the templates in any folder off  the  root folder.

My question is if a template, such as /Members/Index.cfm, invokes a method from the CFC library does the Application.cfc template in the /Admin/cfcs folder get executed or is the root Application.cfc the one executed.

I believe it's just the root one but I'm not 100% sure. 

Any thoughts???  Does having an Application.cfc in the library folder cause any issues???

Thanks in advance for the assist!

Your assumption is correct.  The application.cfc in /Admin/cfc is not being executed, at all, unless there is a .cfm file that is being somehow utilized.  The CF Server first searches the current .cfm document folder for application.cfc/cfm; if it doesn't find it, it keeps recursively searching lower and lower folders until it finds an application.cfc/cfm and executes it.  CFCs in a folder with an application.cfc/cfm do not execute another application.cfc/cfm; they rely on the one that was already executed before loading the requested .cfm file.

HTH,

^_^

Views

273

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 22, 2016 0
LEGEND ,
Jun 22, 2016

Copy link to clipboard

Copied

Your assumption is correct.  The application.cfc in /Admin/cfc is not being executed, at all, unless there is a .cfm file that is being somehow utilized.  The CF Server first searches the current .cfm document folder for application.cfc/cfm; if it doesn't find it, it keeps recursively searching lower and lower folders until it finds an application.cfc/cfm and executes it.  CFCs in a folder with an application.cfc/cfm do not execute another application.cfc/cfm; they rely on the one that was already executed before loading the requested .cfm file.

HTH,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 22, 2016 1
Engaged ,
Jun 24, 2016

Copy link to clipboard

Copied

That's what I thought too.  I just wanted to be sure there wasn't anything special happening behind the scenes when including a file from a directory that also has an App.cfc file.

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 24, 2016 0