Cfinclude with Application.cfc

I am working on migrating an application from ACF to Lucee. As part of our existing application, we use “nested” Application.cfc files. By this, I mean that in the / directory, we have an Application.cfc file that sets some variables like this:

<cfcomponent output="false">

  <!--- Name the application. --->
  <cfset this.name="APPNAME">
  
  <!--- Turn on session management. --->
  <cfset this.sessionManagement="Yes">
  
  <!---Set the default datasource for all pages--->
  <cfset this.datasource = "asdf" />

  <!---Set the default filer location--->
  <cfset this.filer = "blah.asdf.com" />

<cffunction
        name="onRequest"
        access="public"
        returntype="void"
        output="true"
        hint="I execute the requested template.">

        <!--- Define arguments. --->
        <cfargument
            name="template"
            type="string"
            required="true"
            hint="I am the user-requested template." />

        <!--- Include the requested template. --->
        <cfinclude template="#arguments.template#" />

        <!--- Return out. --->
        <cfreturn />
    </cffunction>

</cfcomponent> 

Then, in the /subdirectory, we have an Application.cfc like this:

<cfcomponent output="false">

<!--- Include the default application.cfc file. --->
<cfinclude template="/Application.cfc">

</cfcomponent>

In ACF, this works fine and we can use the this.* variables on any of the pages in /subdirectory. However, in Lucee, the this.* variables are not available:

It seems that using cfinclude for the Application.cfc file does not behave the same in Lucee as it does in ACF. I have tried changing the Application listener mode to different values, but it still doesn’t seem to work. Any ways to get this to work like ACF does?

Lucee (Gelert) Os 5.3.8.206 (CFML Version 2016,0,03,300357)

Jason

I would extend rather than include the parent Application.cfc

/subdirectory/Application.cfc

<cfcomponent extends="../Application" output="false">

<cfdump var="#this.filer#">

</cfcomponent>
2 Likes

That works!! Thank you!!

Jason

1 Like