Skip to main content
Inspiring
January 22, 2014
Question

Crappy Mappings, ie, Crappings

  • January 22, 2014
  • 2 replies
  • 656 views

So correct me if I'm wrong.  I have a file structure that looks like this:

models

> framework

>> alpha.cfc

application.cfc

I am executing from application.cfc.  In it, I have created a mapping (NOTE THE DIFFERENCE IN SINGULAR/PLURAL):

<cfset this.mappings[ '/model' ] = expandPath( '/models/framework' ) />

When I dump the this.mappings structure, I expectedly get:

c:\path\to\webroot\models\framework

So I now dump this code:

<cfdump var="#fileExists( expandPath( '/model/alpha.cfc' ) )#" />

And sure, enough, I get: YES

So here's my problem.  I had always thought that in dot notation syntax, ColdFusion looked at the first value provided and did a mapping check on it.  However, when I run:

<cfset myNewAlpha = new model.alpha() />

I get a message saying the CFC cannot be found.  Only by typing the following:

<cfset myNewAlpha = new '/model.alpha'() />

Does it actually work and find the CFC through dot notation my using the this-scope mapping.

So, is there something I'm missing as to why I can't just call nameOfMapping.path.to.cfc rather than having to make a literal string out of it?

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    January 23, 2014

    You are right: it should work as you expect! Since it fails, this might be an indication that expandPath( '/models/framework' ) and c:\path\to\webroot\models\framework\ are not the same.

    To verify, I would test with

    <cfset this.mappings[ '/model' ] = "c:\path\to\webroot\models\framework\" />

    together with

    <cfset myNewAlpha = new model.alpha() />

    Inspiring
    January 22, 2014

    Well, status update.  Even after doing an: applicationStop() and for all practical puposes, killing the application, it seems ColdFusion, the service, holds onto those mappings and caches them.  I actually had to RESTART THE COLDFUSION APPLICATION SERVICE to get it to release those mappings, and now I can use the: new model.alpha() syntax as expected.

    Sheesh!