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]
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.
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.
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.