using cfinvoke

Discussion in 'Programming' started by ip076, Sep 12, 2007.

  1. #1
    I'm using the cfinvoke tag to invoke a component.

    Goes something like:

    cfinvoke="includes.components.mycomponent"

    It works fine when in a file located in the root directory.

    I've got files that are located in a subdirectory of the root, other than the includes directory.

    How do I refer to the component from another subdirectory?

    In a php include, it would have been easy, "../includes/components/mycomponent.php", but I'm not sure how to do the same using the cfinvoke tag.

    Thanks for the help!
     
    ip076, Sep 12, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think cfinvoke or createObject allow relative paths. Afaik you must use the full path

    <cfinvoke="full.path.to.component.mycomponent" ...>

    One option is to store the root path in an application variable and use it in your code. So if you ever have to change the path, you only need to do it in once place.

    <cfinvoke="#application.cfcRootPath#mycomponent" ...>
     
    cfStarlight, Sep 12, 2007 IP
  3. ip076

    ip076 Peon

    Messages:
    79
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the response.

    I'm trying to use this now:

    <cfinvoke component="#AppRootPath#includes.components.database"
       method="ReturnQuery"
             argumentcollection=#Qry#
       returnvariable="QryResults"></cfinvoke>
    Code (markup):
    where #AppRootPath# is "oracle.FUSD.www.flightwx."

    This should be the full root path.

    I still get this error Could not find the ColdFusion Component oracle.FUSD.www.flightwx.includes.components.database


    Like I mentioned before, I have a "sections" subdirectory and a "includes" subdirectory in my root directory. This file is in the "sections" subdirectory, and the component is in the "components" subdirectory of the "includes" directory.

    Thanks!
     
    ip076, Oct 1, 2007 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The path is generally a CF Mapping to either a folder that is outside the webroot
    or the dot-notation path to a subfolder of the webroot.

    What is your webroot and where are your components located?

    Example:
    CF webroot: /
    physical path: c:\cfusionmx7\wwwrooot
    components are located: c:\cfusionmx7\wwwrooot\includes\components
     
    cfStarlight, Oct 1, 2007 IP