CFComponent extends confusion

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default CFComponent extends confusion

    Has any one figured out the proper behaviour of the EXTENDS attribute to
    CFCOMPONENT. I haven't been able to find out how this attribute is
    supposed to work.

    I have written components that extend other components, that's simple
    enough.

    We did a test to see how CFMX6.1 finds components when using the extend
    attribute and although what we've done works, we don't know why.

    For example we created the following component /folder_a/test.cfc which
    extends a component in /folder_b/base_test.cfc.

    The EXTENDS attribute of test.cfc contains "folder_b.base_test.cfc".

    We then wrote a script /folder_a/test.cfm that instantiates this
    component. And wonderfully, it works.

    My question is why?

    How does CFMX6.1 know to find the component in /folder_b/base_test.cfc.

    Our setup doesn't have a mapping that points to the root of folder_a or
    folder_b.

    Anyone have any clue?

    Thank You


    --

    Don Vaillancourt
    Director of Software Development
    WEB IMPACT INC.
    phone: 416-815-2000 ext. 245
    fax: 416-815-2001
    email: [email]donv@web-impact.com[/email] <mailto:donv@webimpact.com>
    web: [url]http://www.web-impact.com[/url]
    address: [url]http://www.mapquest.ca[/url]
    <http://www.mapquest.com/maps/map.adp?country=CA&addtohistory=&formtype=address& searchtype=address&cat=&address=99%20Atlantic%20Av e&city=Toronto&state=ON&zipcode=M6K%203J8>
    Web Impact Inc. <http://www.web-impact.com>
    This email message is intended only for the addressee(s) and contains
    information that may be confidential and/or copyright.

    If you are not the intended recipient please notify the sender by reply
    email and immediately delete this email.

    Use, disclosure or reproduction of this email by anyone other than the
    intended recipient(s) is strictly prohibited. No representation is made
    that this email or any attachments are free of viruses. Virus scanning
    is recommended and is the responsibility of the recipient.
    Don Vaillancourt Guest

  2. Similar Questions and Discussions

    1. How to extends a datagrid
      Hi, I want to write my own datagrid. I defined it as: import mx.controls.DataGrid; class MyDataGrid extends DataGrid { }
    2. CFC extends
      I have an application which uses about 7 CFC's that takes care of all my business logic. However they do not relate to each and i would like to...
    3. class extends TextFields
      I want to create a class that extends TextField, but there is no way (that I can see) to impliment this. I can't set the AS2.0 class the way I can...
    4. import and extends issue
      I have a class that I declared in a file: Classes/charts/BaseChart.as as class charts.BaseChart { ... I then have a sub-class in file:...
    5. [PHP] PHP class and extends
      You can do one of 2 things. 1. You can comment out the ExecuteQuery Function in the child class. 2. When you call the function in the child...
  3. #2

    Default Re: CFComponent extends confusion

    CFCs are always referenced from the route. You can get away with relationally referencing them on occasion but can lead to problems so it is best avoided.
    Stressed_Simon Guest

  4. #3

    Default Re: CFComponent extends confusion

    That's my question. What is the root?

    If you read my previous email, you'll noticed that there is no hint of a
    root. All mappings that were pointing to the root of my website which
    could be c:\inetpub\wwwroot were changed to point to somewhere else and
    still the example worked.

    Stressed_Simon wrote:
    > CFCs are always referenced from the route. You can get away with relationally referencing them on occasion but can lead to problems so it is best avoided.
    --

    Don Vaillancourt
    Director of Software Development
    WEB IMPACT INC.
    phone: 416-815-2000 ext. 245
    fax: 416-815-2001
    email: [email]donv@web-impact.com[/email] <mailto:donv@webimpact.com>
    web: [url]http://www.web-impact.com[/url]
    address: [url]http://www.mapquest.ca[/url]
    <http://www.mapquest.com/maps/map.adp?country=CA&addtohistory=&formtype=address& searchtype=address&cat=&address=99%20Atlantic%20Av e&city=Toronto&state=ON&zipcode=M6K%203J8>
    Web Impact Inc. <http://www.web-impact.com>
    This email message is intended only for the addressee(s) and contains
    information that may be confidential and/or copyright.

    If you are not the intended recipient please notify the sender by reply
    email and immediately delete this email.

    Use, disclosure or reproduction of this email by anyone other than the
    intended recipient(s) is strictly prohibited. No representation is made
    that this email or any attachments are free of viruses. Virus scanning
    is recommended and is the responsibility of the recipient.

    Don Vaillancourt Guest

  5. #4

    Default Re: CFComponent extends confusion

    Here is a URL that a colleage of mine found:

    A couple of the Macromedia guys posted comments, but the use of EXTENDS
    is still extremely vague.

    [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/buildi12.htm[/url]



    Don Vaillancourt wrote:
    > Has any one figured out the proper behaviour of the EXTENDS attribute to
    > CFCOMPONENT. I haven't been able to find out how this attribute is
    > supposed to work.
    >
    > I have written components that extend other components, that's simple
    > enough.
    >
    > We did a test to see how CFMX6.1 finds components when using the extend
    > attribute and although what we've done works, we don't know why.
    >
    > For example we created the following component /folder_a/test.cfc which
    > extends a component in /folder_b/base_test.cfc.
    >
    > The EXTENDS attribute of test.cfc contains "folder_b.base_test.cfc".
    >
    > We then wrote a script /folder_a/test.cfm that instantiates this
    > component. And wonderfully, it works.
    >
    > My question is why?
    >
    > How does CFMX6.1 know to find the component in /folder_b/base_test.cfc.
    >
    > Our setup doesn't have a mapping that points to the root of folder_a or
    > folder_b.
    >
    > Anyone have any clue?
    >
    > Thank You
    >
    >
    --

    Don Vaillancourt
    Director of Software Development
    WEB IMPACT INC.
    phone: 416-815-2000 ext. 245
    fax: 416-815-2001
    email: [email]donv@web-impact.com[/email] <mailto:donv@webimpact.com>
    web: [url]http://www.web-impact.com[/url]
    address: [url]http://www.mapquest.ca[/url]
    <http://www.mapquest.com/maps/map.adp?country=CA&addtohistory=&formtype=address& searchtype=address&cat=&address=99%20Atlantic%20Av e&city=Toronto&state=ON&zipcode=M6K%203J8>
    Web Impact Inc. <http://www.web-impact.com>
    This email message is intended only for the addressee(s) and contains
    information that may be confidential and/or copyright.

    If you are not the intended recipient please notify the sender by reply
    email and immediately delete this email.

    Use, disclosure or reproduction of this email by anyone other than the
    intended recipient(s) is strictly prohibited. No representation is made
    that this email or any attachments are free of viruses. Virus scanning
    is recommended and is the responsibility of the recipient.
    Don Vaillancourt Guest

  6. #5

    Default Re: CFComponent extends confusion

    On 2005-06-09 10:57:14 -0500, Don Vaillancourt <donv@webimpact.com> said:
    > Here is a URL that a colleage of mine found:
    >
    > A couple of the Macromedia guys posted comments, but the use of EXTENDS
    > is still extremely vague.
    >
    > [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/buildi12.htm[/url]
    A few comments--first, the order in which CF looks for components in
    that link above is actually pretty helpful for the discussion. Unless
    I'm misunderstanding your question is what the "root" of the site is,
    so I'll focus on that. Just bear in mind that list in the link
    outlines where CF looks.

    The "root" would be the docroot of the web server (e.g.
    C:\Inetpub\wwroot by default on Windows). So let's say you have the
    following directory structure:

    mydocroot
    mycfcs
    cfcgroup1

    Now let's say IN the mycfcs directory you have a CFC called base.cfc.
    To instantiate that component you would do this:
    CreateObject("component", "mycfcs.base");

    CF goes to inside the mydocroot directory, finds mycfcs, then in there
    finds base.cfc and knows that's the correct component.

    Next let's say in cfcgroup1 you have a component child.cfc that extends
    base. That would be done this way:
    <cfcomponent displayname="Child" extends="mycfcs.base">
    <!--- etc. --->

    Note that you don't need the ".cfc" at the end of your extends
    statement. So what CF does with the extends statement is starts at
    your web server's docroot (i.e. inside the mydocroot directory) and
    just traverses down the dot notation (aka package notation) until it
    finds the CFC specified.

    Let me know if that doesn't make sense or didn't address your question.

    Matt
    --
    Matt Woodward
    [email]mpwoodward@gmail.com[/email]
    Team Macromedia - ColdFusion

    mpwoodward *TMM* Guest

  7. #6

    Default Re: CFComponent extends confusion

    You pretty much confirmed what I had figured out.

    But in regards to the root. When I started working with ColdFusion on
    version 4.5 the manual stated that ColdFusion had no knowledge of a
    webroot. CF was oblivious to C:\InetPub\wwwroot\ which is why I have
    this problem understanding what root is.

    But from what you've said and what's on that link, CFMX knows the
    webroot of the current cfm module it is currently executing.

    Is that correct?


    mpwoodward *TMM* wrote:
    > On 2005-06-09 10:57:14 -0500, Don Vaillancourt <donv@webimpact.com> said:
    >
    >> Here is a URL that a colleage of mine found:
    >>
    >> A couple of the Macromedia guys posted comments, but the use of
    >> EXTENDS is still extremely vague.
    >>
    >> [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/buildi12.htm[/url]
    >
    >
    > A few comments--first, the order in which CF looks for components in
    > that link above is actually pretty helpful for the discussion. Unless
    > I'm misunderstanding your question is what the "root" of the site is, so
    > I'll focus on that. Just bear in mind that list in the link outlines
    > where CF looks.
    >
    > The "root" would be the docroot of the web server (e.g.
    > C:\Inetpub\wwroot by default on Windows). So let's say you have the
    > following directory structure:
    >
    > mydocroot
    > mycfcs
    > cfcgroup1
    >
    > Now let's say IN the mycfcs directory you have a CFC called base.cfc.
    > To instantiate that component you would do this:
    > CreateObject("component", "mycfcs.base");
    >
    > CF goes to inside the mydocroot directory, finds mycfcs, then in there
    > finds base.cfc and knows that's the correct component.
    >
    > Next let's say in cfcgroup1 you have a component child.cfc that extends
    > base. That would be done this way:
    > <cfcomponent displayname="Child" extends="mycfcs.base">
    > <!--- etc. --->
    >
    > Note that you don't need the ".cfc" at the end of your extends
    > statement. So what CF does with the extends statement is starts at your
    > web server's docroot (i.e. inside the mydocroot directory) and just
    > traverses down the dot notation (aka package notation) until it finds
    > the CFC specified.
    >
    > Let me know if that doesn't make sense or didn't address your question.
    >
    > Matt
    --

    Don Vaillancourt
    Director of Software Development
    WEB IMPACT INC.
    phone: 416-815-2000 ext. 245
    fax: 416-815-2001
    email: [email]donv@web-impact.com[/email] <mailto:donv@webimpact.com>
    web: [url]http://www.web-impact.com[/url]
    address: [url]http://www.mapquest.ca[/url]
    <http://www.mapquest.com/maps/map.adp?country=CA&addtohistory=&formtype=address& searchtype=address&cat=&address=99%20Atlantic%20Av e&city=Toronto&state=ON&zipcode=M6K%203J8>
    Web Impact Inc. <http://www.web-impact.com>
    This email message is intended only for the addressee(s) and contains
    information that may be confidential and/or copyright.

    If you are not the intended recipient please notify the sender by reply
    email and immediately delete this email.

    Use, disclosure or reproduction of this email by anyone other than the
    intended recipient(s) is strictly prohibited. No representation is made
    that this email or any attachments are free of viruses. Virus scanning
    is recommended and is the responsibility of the recipient.
    Don Vaillancourt Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139