• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Crappy Mappings, ie, Crappings

Enthusiast ,
Jan 22, 2014 Jan 22, 2014

Copy link to clipboard

Copied

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?

Views

522

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 22, 2014 Jan 22, 2014

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2014 Jan 23, 2014

Copy link to clipboard

Copied

LATEST

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() />

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation