Application.cfc Feature Request

I have to start this entry with a confession. I don't use Application.cfc, except on one web site (and I'm not convinced that I should have used it there). In theory, I like it. So far, however, it hasn't been worth the trouble.

This got me thinking, exactly what trouble do I think it is to use Application.cfc, anyway?

[More]

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Brian, I get the point but honestly in many years I never had occasion or desire or need to extend application.cfm or later .cfc.
I am just wonderign why are you using so much this architecture? Some exmaple??

Andrea
# Posted By Andrea | 12/31/08 7:59 AM
Andrea,

Good point. I should have included an example.

Let's say that I have a variable that I want set for every file in a folder. Perhaps, I want to indicate that each file in the folder is in the "About" section. I might want to do:
<cfset Section = "About">

Instead of including that in each file, it would be easier to put it in an Application.cfm in that folder. I still need the parent Application.cfm to execute though, so I add <cfinclude template="../Application.cfm">

Now, I know that this problem can be circumvented altogether by other framework or architecture decisions, but that is hardly the point. I want ColdFusion to make my life easy.
# Posted By Steve Bryant | 12/31/08 8:13 AM
Here is the one I just ran into:

I have a folder in which I want to set a folder-specific onMissingTemplate method. I don't want to do anything else with Application.cfc but that. I still need the site Application.cfc to execute.

My typical process to install a folder is to drop it in the site and have it just work. I don't want to have to know if the folder is one folder down from the root or five. I just want the thing to work.
# Posted By Steve Bryant | 12/31/08 8:15 AM
Steve, have you tried to extend an Application.cfc to a parent with a cfmapping in place? The reason I ask is because of how Fusebox 5 works. I have a Fusebox 5 application with its own Application.cfc. When you open that component, it extends fusebox5.Application. I have a mapping for fusebox5 in my CFAdministrator and each method so that CF knows how to find the Fusbox 5 core files and such. Within the application's Application.cfc, all methods start with a call to super():
# Posted By Craig Kaminsky | 12/31/08 9:35 AM
Hey, not at sure why you want to nest Applicaiton.cfc still, so bear with me. My take is encapsulation of purpose. The application class object may connect to other components and .cfm files but I wouldn't be putting 'fluid' or 'custom' code inside an Application.cfc file. That is again just the way we approach things. FFT is the fact that making the core application file solid has not kept us from designing it into a framework that ends up being VERY flexible. :)
# Posted By John Farrar | 12/31/08 1:31 PM
Craig,

It is probably a personal thing, but I really don't like mappings.

In my case, I want to be able to just drop a folder in the site and *not* have any requirements for the site that the folder is being dropped into for it to work. This is just really important to me and anything that gets in the way of that is a frustration.

John,

That does make sense. I actually gave an example in the comments. Specifically, I just want a custom onMissingTemplate applied to one folder.

I don't want to have to know what framework is or isn't being used or use a framework-specific answer. It just really seems like CF should make this easy. Isn't that the point of CF, after all?
# Posted By Steve Bryant | 12/31/08 1:42 PM
@Steve,
The onMissingMethod() concept does seem like it would be nice, but if you are not routing you should be able to use the CGI variables to deal with the location of the requested file. From there you could create a 'handler' that was not hard coded into your application.cfc file and let you handle things based on the type of request. Pragmatically speaking any handler is going to have to handle it according to the 'application framework' being used. Even stand alone templates is a framework of a kind. :) They don't need to add anything to ColdFusion 9 for this... we can do it now. (As far as I understand your request that is.)
# Posted By John Farrar | 12/31/08 2:50 PM
I agree with john,
I usually add simple handler method inside application.cfc methods and handle things differently. My application.cfc is 99% always the same file.
# Posted By Andrea | 1/1/09 2:44 AM
John,

I guess I must be dim - I am not following that at all.

Care to elaborate?
# Posted By Steve Bryant | 1/1/09 6:46 AM
you don't need to use that applicationproxy trick in order to extend the application.cfc. if you want to extend the root application.cfc in a subdirectory, just use:

cfcomponent extends="/.application"
# Posted By tony petruzzi | 1/2/09 7:27 AM
Tony,

I tried that on CF8 and it didn't work. Does this only work on Railo or BlueDragon perhaps?
# Posted By Steve Bryant | 6/24/09 5:42 PM
don't know why it didn't work for you. i'm using this exact trick in a current application i've written. maybe I was clear on the tactic. you can your root application.cfc from any application.cfc that is in a subdirectory by using the extends="/.application":

<!--- this application.cfc live in a subdirectory from the root --->
<cfcomponent extends="/.application">
# Posted By tony petruzzi | 6/24/09 6:47 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.