1

I have a test application structured like so:

  • Application.cfc
  • ApplicationProxy.cfc
  • index.cfm
  • sub_app/
    • Application.cfc
    • index.cfm

and I want my sub app to inherit all variables and events from the top level Application.cfc.

I have read and implemented Sean Corfield's ApplicationProxy method for extending an Application component but I can't get it to work as when I visit sub_app/index.cfm I get this error:

Could not find the ColdFusion Component or Interface ApplicationProxy.

From the error I can only guess that the application is looking in the wrong place, how do I correct this?

Application.cfc:

<cfcomponent name="Application" output="true">

<cfset THIS.name = "testAppA">
<cfset THIS.sessionManagement="Yes">
<cfset THIS.applicationTimeout = createTimeSpan(0,0,10,0)>
<cfset THIS.sessionTimeout = createtimespan(0,0,10,0)>
<cfset THIS.clientManagement = true>
<cfset THIS.clientStorage = "cookie">
<cfset THIS.loginStorage = "cookie">
<cfset THIS.setDomainCookies = false>
<cfset THIS.setClientCookies = true>
<cfset THIS.scriptProtect = true>
<cfset THIS.secureJSON = true> 

<cffunction name="onApplicationStart" returntype="void">

    <cfset APPLICATION.name = "testAppA">
    <cfset APPLICATION.test = "test var">

</cffunction>

<cffunction name="onSessionStart" returntype="void">

    <cfset SESSION.loggedIn = 1>

</cffunction>    

</cfcomponent>

ApplicationProxy:

<cfcomponent name="ApplicationProxy" extends="Application">
</cfcomponent>

index.cfm:

<a href="sub_app/index.cfm">Sub app</a>

sub_app/Application.cfc:

<cfcomponent extends="ApplicationProxy" output="true">

    <!---

            Uses parent Application settings

    --->

</cfcomponent>

sub_app/index.cfm:

<a href="../index.cfm">Parent app</a>

<cfdump var="#Application#">
Miguel-F
  • 13,450
  • 6
  • 38
  • 63
eb_dev
  • 107
  • 1
  • 8
  • Perhaps this other answer will help explain it: [Extending application.cfc in a subdirectory](http://stackoverflow.com/questions/307423/extending-application-cfc-in-a-subdirectory/307441#307441) – Miguel-F Jun 19 '13 at 12:51

1 Answers1

1

Best way to do is create ApplicationProxy.cfc file with all function you need to inherit and then extends in Application.cfc wherever needed. I am using this method since long time and no issue face with this approach.

Pritesh Patel
  • 1,969
  • 1
  • 18
  • 32