Skip to main content
eleonf
New Participant
June 4, 2018
Question

extending an application.cfc, but giving it, it's own application name.

  • June 4, 2018
  • 1 reply
  • 1346 views

Hello,

I am extending an application.cfc from another directory. In my parent application.cfc I have:

<cfcomponent>

this.name=hash( getCurrentTemplatePath());

in the child I have:

<cfcomponent extends="rootapplication">   

    this.name="child";

It looks like the child "this.name" never runs. No matter what i do they share the same application scope and a change in one changes both (as they have the same application name).

So I have two questions (different ways to fix the same problem):

1. Is there a way to change the application name?

2. Is there a better hash tag I can use for the parent this.name such that when run from a different directory it has a different value?.

I was hoping the getCurrentTemplatePath would load the child path when the parent is extended (which would fix all my problems). Is there an easier solution before I bang on this some more, as this has been rather frustration (this scope in application.cfc seems to be protected from anything not in the parent application.cfc).

Thanks,

-Eleon

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    June 4, 2018

    Follow Daniel Short's steps for extending Application.cfc, and you will be all right.

    eleonf
    eleonfAuthor
    New Participant
    June 4, 2018

    I have read about 20 articles on how to do it (including this one a few days ago), and they are all worried about how to use a file with the same name, and this article is only talking about how to extend an application.cfc with the same name.

    I have the extension works,the use of supper scope and more or less everything, except that application name for the application scope.The child application is just appending onto the other application in memory and not creating it's own application memory space, because i can not easily change the name in the child.

    The "this" scope variables in the child cfc do not fire and do not rename the application cfc (seems like a rather major bug in my mind).

    Odds are I will have to get very creative in the parent application.cfc to get this working, but that is an ugly hack, and there really should be an easier way to do this.

    eleonf
    eleonfAuthor
    New Participant
    June 7, 2018

    I thought there might be a problem with your extension tree. Supposing not, then I shall now assume that the child extends a component called rootApplication which in turn extends the parent. I can see no reason why the this.name value will be the same for parent and child.

    Do all 3 CFCs have a distinct value for this.name?

    I created a similar test, in which I ran <cfdump var="#application#"> in the OnRequestStart of the child and of the parent. The dumps showed distinct application names.


    the rootapplication.cfc is just an include of the application.cfc of the parent application (I was trying to avoid extending of an extension). So rootapplication.cfc just has an include line in it.

    All of them have unique names for "this.name".

    I could never get the child to change the application name..

    I did finally hack a solution, by doing a hash of the root URL for this.name in the parent application.cfc such that iit is a dynamic hash (I could not use a hash of the current template).

    So while I was able to hack a solution, I still am mystified why this.name will not set anything when called from the child.

    Thanks,

    -Eleon