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

path to cfc

Contributor ,
Feb 21, 2007 Feb 21, 2007

Copy link to clipboard

Copied

I have tried what the documentation says to do but can't get this to work.

How do I call CFCs that reside in a folder above the current folder?

The documentation says just to use the path but use dots instead.

So com.cfcs.mycfc But this doesn't work.
TOPICS
Advanced techniques

Views

556

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
LEGEND ,
Feb 21, 2007 Feb 21, 2007

Copy link to clipboard

Copied

> So com.cfcs.mycfc But this doesn't work.

"doesn't work".

Can you elaborate on that? What - exactly - happens to make you think it
doesn't work? And what - exact - code are you using which causes this?

--
Adam

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 ,
Feb 21, 2007 Feb 21, 2007

Copy link to clipboard

Copied

So com.cfcs.mycfc But this doesn't work.
Show us the directory structure of the cfm page and of the cfc. Otherwise, it's difficult to say.

Suppose your cfc is someDirStructure/com/cfcs/mycfc.cfc. Then the code

<cfset obj = createObject("component","com.cfcs.mycfc")>

will work if you put it in any of the following pages

someDirStructure/testPage.cfm
someDirStructure/com/testPage.cfm
someDirStructure/com/cfms/testPage.cfm

arbitraryDirStructure/testPage.cfm (if you have declared a "com" mapping in the Coldfusion Administrator)




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
LEGEND ,
Feb 21, 2007 Feb 21, 2007

Copy link to clipboard

Copied

i think Dinghus is asking about a case when
cfc is in someDirStructure/com/cfcs/mycfc.cfc

and createObject script is in a page in
someDirStructure/com/anotherDir/yetAnotherDir/testPage.cfm

or maybe even
someDirStructure/anotherDir/yetAnotherDir/testPage.cfm

will reference com.cfcs.mycfc still work from those locations?

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

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
LEGEND ,
Feb 22, 2007 Feb 22, 2007

Copy link to clipboard

Copied

Azadi wrote:
> cfc is in someDirStructure/com/cfcs/mycfc.cfc

> will reference com.cfcs.mycfc still work from those locations?

no, you should provide the full path to the CFC
(someDirStructure.com.cfcs.mycfc). someDirStructure should be off the web root &
of course web accessible. or better yet use cf mapped dir.


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 ,
Feb 22, 2007 Feb 22, 2007

Copy link to clipboard

Copied

someDirStructure should be off the web root & of course web accessible.
An important consideration my example only assumes, but should have stated explicitly.

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
LEGEND ,
Feb 22, 2007 Feb 22, 2007

Copy link to clipboard

Copied

> someDirStructure should be off the web root &
> of course web accessible. or better yet use cf mapped dir.

CFCs don't NEED to be either in the webroot or web accessible, unless
they're being used as web services, do they?

--
Adam

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
LEGEND ,
Feb 22, 2007 Feb 22, 2007

Copy link to clipboard

Copied

CFCs don't NEED to be either in the webroot or web accessible, unless
they're being used as web services, do they?

I don't think they NEED to, but that the webroot is one of the
automatically searched paths if one does not have a mapping.

That is my understanding anyway.

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
Guest
Feb 23, 2007 Feb 23, 2007

Copy link to clipboard

Copied

here is the solution to it

You create a mapping in the cf Administrator for the topmost folder
and then you can access anywhere using the dot operators along with the mapping name

for example
if you have a cfc at the level -- "mainfolder/subfolder/nextsubfolder/required.cfc"
you need to create a mapping
say name = com , path = physical path to "mainfolder"
Now you can access the required.cfc by creating an object as follows--
<cfset obj = createObject("component","com.subfolder.nextsubfolder.required")>

Good Luck

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
LEGEND ,
Feb 23, 2007 Feb 23, 2007

Copy link to clipboard

Copied

LATEST
Ian Skinner wrote:
> CFCs don't NEED to be either in the webroot or web accessible, unless
> they're being used as web services, do they?

if they're not in a cf mapped dir, custom tag dir, etc yes i think they do need
to be web accessible in one form or another. otherwise how would you find them?

created a CFC junk.cfc, tossed into c:\data on the server, data dir is *not* web
accessible.

<cfscript>
j=createObject("component","data.junk");
</cfscript>

"Could not find the ColdFusion Component data.junk."

if you don't use a cf mapped dir or one of its searched dirs, the CFCs need to
reside in web accessible dirs. maybe one of cf's classpaths will work but i
wouldn't let any tom, dick or harry mess around in those.

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