继承其他函数的ColdFusion组件 [英] ColdFusion Components Inheriting Functions Of Others

查看:143
本文介绍了继承其他函数的ColdFusion组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个简单的CFC,如下所示:



Test1.cfc

 < cfcomponent> 
< cffunction name =initMethod1access =privatereturntype =boolean>
< cfreturn true />
< / cfcomponent>

Test2.cfc

 < cfcomponent> 
< cffunction name =initMethod2access =privatereturntype =boolean>
< cfreturn true />
< / cfcomponent>

在Application.cfc的OnApplicationStart()期间,我进行以下调用:

 < cfset application [Test1] = CreateObject(component,jbx.c.Test1)/ 
< cfset application [Test2] = CreateObject(component,jbx.c.Test2)/>

当我转储应用程序范围时,注意下面这两个组件都有自己的功能,人的功能。任何想法为什么这是,如何纠正它?谢谢。





解决方案

因为你绑定了onApplicationStart(),它们是在你第一次打开该网站时创建的。重置应用程序变量的快捷方法是重命名应用程序。



当我开发cfc时,我知道将要在应用程序范围内,在请求范围内的细节,那么一旦这是正确的工作,我移动应用程序的范围。



另一件有用的调试这些类型的问题是

  application.initialized = now(); 

这样当转储应用程序范围时, p>

I have two simple CFCs as shown below:

Test1.cfc

<cfcomponent> 
  <cffunction name="initMethod1" access="private" returntype="boolean"> 
  <cfreturn true />
</cfcomponent>

Test2.cfc

<cfcomponent> 
  <cffunction name="initMethod2" access="private" returntype="boolean"> 
  <cfreturn true />
</cfcomponent>

During OnApplicationStart() of Application.cfc, I make the following calls:

<cfset application["Test1"] = CreateObject("component","jbx.c.Test1") />
<cfset application["Test2"] = CreateObject("component","jbx.c.Test2") />

When I dump the application scope, notice below that both components have their own function as well as the other one's function. Any idea why this is and how to correct it? Thanks.

解决方案

Because you tied this with onApplicationStart(), they were create when you first hit that web site. A quick way to reset the application variables is to rename the application.

When I develop cfc's that I know are going to be in the application scope, I work out all the details within the request scope, then once that is working right, I move the the application scope.

Another thing that is useful for debugging these kinds of issues, is to have

application.initialized = now();

That way when you do a dump of the application scope, you know when it was setup.

这篇关于继承其他函数的ColdFusion组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆