2 Replies Latest reply on Jan 23, 2014 5:07 AM by BKBK

    Crappy Mappings, ie, Crappings

    Aegis Kleais Level 3

      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?

        • 1. Re: Crappy Mappings, ie, Crappings
          Aegis Kleais Level 3

          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!

          1 person found this helpful
          • 2. Re: Crappy Mappings, ie, Crappings
            BKBK Adobe Community Professional & MVP

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