Cannot use parent Application.cfc using RootProxy


#1

I have a legacy application that consists of multiple individual applications. There’s a root folder and each application resides in its individual subfolder. To share functionality each application inherits from a central Application.cfc after a pattern introduced by Ben Nadel.
To use this site under Lucee I use commandbox. I call start and navigate to the subfolder.
I get error: Component [site1.Application] has no accessible Member with name [WEBROOT]

https://www.bennadel.com/blog/2115-extending-the-application-cfc-coldfusion-framework-component-with-a-relative-path-proxy.htm

This code, however, works in ACF. I have no Lucee server running so I cannot say if it’s an issue with Lucce or with the way Commandbox handles Lucee.

I put the relevant files in a Gist

https://gist.github.com/bardware/5a34c49b74c7bbba4d8adae80fbc84fa

Does Lucee handle includes differently than ACF and does therefore not accept a parent setup like I described?


#2

If there’s no dependencies inside the root Application.cfc outside of what you’ve outlined, then these two are equivalent:

Application.cfc

<cfset this.webroot = GetDirectoryFromPath(GetCurrentTemplatePath())>

site1\Application.cfc

<cfset this.webroot = this.webroot & "/site1">

In other words, you could just use GetDirectoryFromPath(GetCurrentTemplatePath()) in site1\Application.cfc instead of including the root Application.cfc and then using this.webroot & "/site1".

Beyond that, however, the more common approach is to use the same this.name in all of your Application.cfc's which allows sub-folders of the root to inherit the properties defined in the root Application.cfc. So, if you have additional dependencies beyond this.webroot then that’s probably a better approach. And, in which case, this.webroot = GetDirectoryFromPath(GetCurrentTemplatePath()) in each Application.cfc would be used.

EDIT: Quick caveat now that I think of it… you say you’re browsing to the subfolder so the above this.name approach should work (assuming you have dependencies outside of the this.webroot that aren’t already resolved by my first suggestion).

If, however, you were to have a domain/site/vhost pointed to that subfolder then the webroot would be that subfolder and the parent (root) Application.cfc would not be invoked. Just something to keep in mind with the this.name approach - it requires the root Application.cfc to always be webroot.

HTH

– Denny


#3

Hi Denny,

thanks for your reply.
My issue is not about the content of the variable. The thing is in ACF I can access a variable from the this scope. It must have been created through the extends attribute and the cfinclude. In Lucee I cannot append to a this scope variable.