In ColdFusion, how do you explicitly reference the “THIS” scope defined in Application.cfc?

与世无争的帅哥 提交于 2019-12-11 01:58:41

问题


Is there a way to explicitly reference the THIS scope defined in Application.cfc?

Say I have an Application.cfc like this:

component {
this.name="MyApplication"
..

I know that from any page in the site, you can access this.name this way...

<cfoutput>#this.name#</cfoutput> 

...but if you are in another component, how would you reach the Application.cfc's "this" scope? Is it possible without handing the var off?

Adobe documentation says that you can reference the "THIS" scope by using the instance or object name as a prefix. I tried Application.this.name but it didn't work.


回答1:


Most of the things that are set in "this" in Application.cfc are not accessible outside the execution of it. ColdFusion copies this.name into application.name at runtime, so you can access application.name from anywhere in your application. For the other settings in "this", they appear to be accessible from your pages because the pages are included into the application.cfc execution cycle by the OnRequest() method.

Once you instantiate a CFC and work inside it's methods, the context of "this" changes to the constructor of that CFC.



来源:https://stackoverflow.com/questions/23795753/in-coldfusion-how-do-you-explicitly-reference-the-this-scope-defined-in-appli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!