Skip to main content
April 28, 2010
Question

difficulty mapping my cfc files

  • April 28, 2010
  • 2 replies
  • 1348 views

All of my .cfc files are stored in a folder called cfc in my

webroot.  I have folders in higher level directories, and I cannot get the

mappings to work so that I can access my cfc's when they are in a lower directory....Can anyone show me a working example of how i might do this?  Ive tried stuff like:

<cfinvoke component="../../cfc.errorBox" method="errorBox" errorarray="#errorarray#" boxwidth="#errorboxwidth#" returnvariable="errorboxstring"></cfinvoke>

But I get an error saying that it couldnt find the cfc file....

Ben

    This topic has been closed for replies.

    2 replies

    April 28, 2010

    Even when I browse to the cfc, it give me its location based on the webroot of my website: "ben.includes.cfc.sendMail", however, there is another folder on my website in the same directory as "ben" that has cfm files that I want to access the cfc's.  When I put the location "ben.includes.cfc.sendMail" in there, it thinks i am trying to navigate to the cfc folder "joel.includes.ben.includes.cfc.sendMail", and that is why its messing up.  Is there no way at all to specify an absolute URL?

    Inspiring
    April 29, 2010

    I have never seen CF not be able to find a CFC via the dotted path the API docs suggest. Indeed the API docs are implemented by instatiating the object, then calling getMetadata() on it. So it CAN be instantiated via that path.

    Show us the code you're using to instantiate the object...

    --

    Adam
    April 29, 2010

    If I make an object from the CFC like this:

    <cfset myCFC=CreateObject("component","cfc.sendMail")>

    in my index file, is the a way that I can invoke the sendMail function in my sendMail.cfc from the objetc I have just created, "myCFC"?

    Inspiring
    April 28, 2010

    You don't path CFCs like that.

    The easiest way to find out what the name of a CFC is is to browse to it.  CF will auto-generate some API docs, the first thing it lists is the dotted path to the CFC.  Of course this only works if your CFCs are web browseable (which they shouldn't be, really; but people usually just bung them in their webroot, so they generally are web browseable...).

    --

    Adam

    April 28, 2010

    Hmmm....is there any way to directly link to my cfc path...for instance - "C:/wwwroot/cfc" something like that?  because I have a lot of directories on my website and I would like to be able to create some variable, maybe like <cfset cfcpath = "C:/wwwroot/cfc"> and then be able to access all my cfcs my saying something like:

    <cfinvoke component="#cfcpath#" method="errorBox" errorarray="#errorarray#" boxwidth="#errorboxwidth#" returnvariable="errorboxstring"></cfinvoke>

    Ive tried doing it that way but it doesnt work....is there any way to do something like that?

    Ben

    Inspiring
    April 28, 2010

    You do not reference a CFC via its filesystem path, so don't worry about that.  You reference it by its dotted path.  And to get the dotted path... um... read what I said in my previous post, I guess ;-)

    --

    Adam