Just checking my knowledge here, about extending a...
# cfml-general
m
Just checking my knowledge here, about extending an application.cfc into a subfolder - Is using an empty proxy.cfc in the root folder that extends the application.cfc still the way to go? (as outlined here)
b
I was following the logic in Gregory's Blog, until I saw this:
<cfcomponent sessionmanagement="yes" clientmanagement="yes">
I had expected the usual
<cfcomponent>
<cfset this.sessionmanagement="yes" >
<cfset this.clientmanagement="yes">
m
yeah, I wouldn't do things exactly the same
I just meant the general structure
d
Yep, we had to do almost this exact thing when migrating from Application.cfm Our Taffy endpoints used to
include Applicaiton.cfm
in the onREquestStart, now they...
Copy code
function onRequestStart( targetPath = "" ) {
		AppProxy = new ApplicationProxy()
		AppProxy.onRequestStart()
		return super.onRequestStart( targetPath );
	}
m
@Dean thanks for the confirmation!
👍 1
b
On checking on the web, I can see that such "proxy" solutions for extending Application.cfc go way back. For example, Dan Short published "Extending the root Application.cfc" in April 2005. I wonder whether you can now solve the problem in a simpler, neater way. The following procedure seems to work: on Adobe ColdFusion 2023, at least: 1. In the ColdFusion Administrator, go to _Server Settings > Mappings, and a_dd the mapping with Logical Path = /appRoot and Directory Path = C:/ColdFusion2023/cfusion/wwwroot 2. Begin the code of the Application.cfc of the subfolder with:
<cfcomponent extends="appRoot.Application">
AppProxy = new ApplicationProxy()
AppProxy.onRequestStart()
@Dean, are you sure about that? I am not. I think ColdFusion/Lucee is the one that has the responsibility to instantiate Application.cfc, not the application itself.
m
@bkbk never thought to do it with a mapping - interesting approach! Thanks for sharing
d
@bkbk not sure I understand your comment, but what I wrote is what we are doing. We dont want to extend the root Application.cfc for reasons, but we do need the variables that
onRequestStart
handles in it.
b
@Dean, what I mean is, if your local Application.cfc extends ApplicationProxy.cfc, then ColdFusion/Lucee will automatically instantiate ApplicationProxy.cfc. That is, ColdFusion/Lucee will evaluate
new ApplicationProxy()
under the bonnet. Inheritance is transitive: if your local Application.cfc extends ApplicationProxy.cfc, and ApplicationProxy.cfc extends the root Application.cfc, then your local Application.cfc extends the root Application.cfc. I am therefore confused by your statement that you "dont want to extend the root Application.cfc".
d
Our local Application.cfc doesnt extend ApplicationProxy, it instantiates it as ApplicationProxy
The local Application.cfc extends taffy.core.api
b
Ah, I see.
g
I need to update and rewrite this article. It got corrupted when I migrated from Hostek to Media3 a year ago. However, the article's point is that you can either extend an application.cfc going down from the root, up from the subdirectory or even use mapping.