检测CFX标签是否已注册

时间:2014-03-25 07:42:32

标签: coldfusion

我为我的应用程序开发了一些自定义标记,但它们可能会也可能不会部署在客户端站点上。如果没有,我想优雅地处理它(通过使用替代方法)。我怎么能这样做?

使用cftry / cfcatch进行检测,但必须有一些更优雅的方法。使用Coldfusion 10.

<!--- Missing custom tag --->
<cftry>
     <cf_blah>
<cfcatch type="Any">
     The specified custom tag does not exist!
     <!--- additional processing here --->
</cfcatch>
</cftry>

1 个答案:

答案 0 :(得分:3)

您可以使用Administrator API管理CFX标记。这是一种入门方式。

createObject("component","cfide.adminapi.administrator").login({password}, {username});
myObj = createObject("component","cfide.adminapi.extensions");

其中{username}是用于登录ColdFusion管理员的用户名称的名称,{password}是该用户的密码。

然后您可以转储myObj以查看可用的方法。

writeDump( myObj );

使用此功能,您应该能够检查CFX标签是否存在,如果需要,可以注册。

可以获得更多信息here