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?
Here it is. When I use Application.cfm and I want to effectively extend a higher level Application.cfm, it is really easy:
The beauty of this isn't just that it is one line of code, it is that I don't have to touch anything outside of the folder containing the Application.cfm that is extending a higher level Application.cfm.
Now, I know that I can extend Application.cfc by use of an ApplicationProxy.cfc, but that requires me to touch the root folder (or always have a proxy).
Furthermore, if I want to extend more than one level deep, I need another name for a mid-level proxy CFC - yuck!
With Application.cfm, I can have an Application.cfm in each folder that includes the higher-level Application.cfm - without having to think about it.
So, what I want in Application.cfc is a simple way to tell it to check for a higher level Application.cfc. Here are some thoughts:
OR
Either way, ColdFusion could respond by continuing to look up the tree as though it hadn't found Application.cfc and have the current one extend that one. This would be just as easy as extending in Application.cfm, but would provide the added benefit that you wouldn't have to know inside the Application.cfc if the higher-level was one folder up or several - just that there was one.
I am just wonderign why are you using so much this architecture? Some exmaple??
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.
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.
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?
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.)
I usually add simple handler method inside application.cfc methods and handle things differently. My application.cfc is 99% always the same file.
I guess I must be dim - I am not following that at all.
Care to elaborate?
cfcomponent extends="/.application"
I tried that on CF8 and it didn't work. Does this only work on Railo or BlueDragon perhaps?
<!--- this application.cfc live in a subdirectory from the root --->
<cfcomponent extends="/.application">