9 Replies Latest reply on Feb 23, 2007 3:48 AM by Newsgroup_User

    path to cfc

    Dinghus Level 1
      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.
        • 1. Re: path to cfc
          Level 7
          > 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
          • 2. Re: path to cfc
            BKBK Adobe Community Professional & MVP
            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)




            • 3. Re: path to cfc
              Level 7
              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
              • 4. Re: path to cfc
                Level 7
                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.


                • 5. Re: path to cfc
                  BKBK Adobe Community Professional & MVP
                  someDirStructure should be off the web root & of course web accessible.
                  An important consideration my example only assumes, but should have stated explicitly.

                  • 6. Re: path to cfc
                    Level 7
                    > 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
                    • 7. Re: path to cfc
                      Level 7
                      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.
                      • 8. Re: path to cfc
                        satbeh
                        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
                        • 9. Re: path to cfc
                          Level 7
                          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.