Skip to main content
Known Participant
September 24, 2015
Question

cfapplication and this.mapping for component

  • September 24, 2015
  • 1 reply
  • 852 views

Hi,

Sorry to ask but I am struck and don't know where to go on.  Any suggestions are appreciated. Here is the structure of the site.  All the components are inside the components directory.  With et directory, I'd like to create an Application.cfc for that.  Files in et directory will call up functions in components directory.  I tried to create this.mappings in et Application.cfc but don't seem to recognize or work.  What do I need in sub Application.cfc (et folder) to call components?

Application.cfc (root application.cfc)

-components folder

-ce folder

-et folder

     - Application.cfc

     -index.cfm

     -test.cfm

With the root Application.cfc, it has the following:

<cfcomponent displayname="Application" output="true" hint="Handle the application.">

<!--- set up per application mappings --->

  <cfset this.mappings = {}>

  <cfset this.mappings["/components"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "components">

  <cfset this.mappings["/ce"] = GetDirectoryFromPath( GetCurrentTemplatePath() )>

    <!--- Set up the application. --->

    <cfset THIS.Name = "Test" />

    <cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 1, 0, 0 ) />

    <cfset THIS.SessionManagement = true />

    <cfset THIS.SessionTimeout = CreateTimeSpan( 0, 1, 0, 0 ) />

    <!---<cfset THIS.SetClientCookies = true />--->

    <cfset THIS.SetClientCookies = false />

    <cfset THIS.loginstorage="Session">

   

</cfcomponent>

    This topic has been closed for replies.

    1 reply

    WolfShade
    Legend
    September 25, 2015

    I could be incorrect, but I believe the application.cfc in your "et" directory is stopping CF from using the application.cfc in the root (CF iteratively looks for an application.cfc - once it finds one, it stops looking.)

    So, your root app mapping is not being set if running .cfm/.cfc from "et" folder.

    You _could_ conceivably set a mapping within your "et" application.cfc to the components folder in the root, but I'm not sure how well that would work.

    V/r,

    ^_^

    BKBK
    Community Expert
    Community Expert
    October 2, 2015

    WolfShade wrote:

    You _could_ conceivably set a mapping within your "et" application.cfc to the components folder

    Bam! That's what I would do, too.