coldfusion - 是否可以针对组件类型和/或继承类型测试对象?

标签 coldfusion cfc

Update: Based on the answers I initially went the route of using IsInstanceOf() which was designed for this need. However it turned out to be extremely inefficient for some unknown reason. In debugging the app later I ended up just setting some properties on the object to use instead of IsInstanceOf resulting in orders of magnitude speed improvement.



我想做的是在 ColdFusion 中测试一个对象,看看它是什么类型的组件。就像是...
<cfif isValid( "compath.dog", currentObj)>
    ...do something specific with dog objects...
</cfif>

我认为这是可能的,但收到一条错误消息,指出我传递的类型与有效类型列表中的类型不对应...

Valid type arguments are: any, array, Boolean, date, numeric, query, string, struct, UUID, GUID, binary, integer, float, eurodate, time, creditcard, email, ssn, telephone, zipcode, url, regex, range , component, or variableName.



有没有办法在 ColdFusion 中实现这一点?

最佳答案

您可以使用 GetMetaData 来查找类型。一些快速代码:

<cfif GetMetaData(currentObj).type eq "compath.dog">

关于coldfusion - 是否可以针对组件类型和/或继承类型测试对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/879388/

相关文章:

Coldfusion 添加查询中的变量

java - Java/ColdFusion 和 Lucee 之间的 identityHashCode 区别

Coldfusion (railo) 和 cfthread 没有按我的预期工作

ajax - 使用 AJAX 响应填充表单字段

javascript - Moment.js 不喜欢我的时间格式

javascript - 循环 JSON 数据以使用 optgroup 部分填充选择框的分析瘫痪

function - 为什么在生产环境下运行时,我无法在实时服务器上调用 Coldfusion CFC 中的函数?

coldfusion - cfc 中的函数局部变量

java - 如何确定 ColdFusion 对象所在的上下文?

Coldfusion 奇怪的额外空间