cfproperty标签定义变量和coldfusion中的变量范围变量有什么区别?

时间:2022-07-19 13:33:56

What is the difference between cfproperty tag defined variable and the variables scope variable in ColdFusion?

cfproperty标签定义的变量和ColdFusion中的变量范围变量有什么区别?

I have Java language experience, can you compare the ColdFusion cfproperty variable, variables scope variable to the Java instance variable and class variable?

我有Java语言经验,你能比较ColdFusion cfproperty变量,变量范围变量到Java实例变量和类变量吗?

greate thanks!

3 个解决方案

#1


CFPROPERTY is only useful for providing metadata for a component. The only time I ever use them is when creating a component for a Web Service, when they're required.

CFPROPERTY仅对提供组件的元数据有用。我唯一使用它们的时候是在需要时为Web服务创建组件。

Here's a TechNote which discusses CFPROPERTY a bit further: http://kb2.adobe.com/cps/191/tn_19169.html

这是一个技术说明,它进一步讨论了CFPROPERTY:http://kb2.adobe.com/cps/191/tn_19169.html

The variables scope is "protected" and only available within the component. The "this" scope variables are public properties. And, of course, any variable declared with the "var" keyword is private to that method.

变量范围是“受保护的”,仅在组件中可用。 “this”范围变量是公共属性。当然,使用“var”关键字声明的任何变量都是该方法的私有变量。

Here's some more on component scopes: http://www.hemtalreja.com/?p=94

以下是有关组件范围的更多信息:http://www.hemtalreja.com/?p = 94

#2


Note: cfproperty tag does NOT defined variables.

注意:cfproperty标记没有定义变量。

However, it is helpful when you use CFC Explorer (browse to the CFC directly), so that you can see the properties of the CFC object.

但是,在使用CFC Explorer(直接浏览到CFC)时很有用,这样您就可以看到CFC对象的属性。

FYI... cfproperty will be much more useful in CF9. See: ORM - Rethinking ColdFusion Database Integration

仅供参考... cfproperty在CF9中会更有用。请参阅:ORM - 重新思考ColdFusion数据库集成

#3


cfproperty is useful when using custom objects in remote methods. For example, suppose I had the following component:

在远程方法中使用自定义对象时,cfproperty非常有用。例如,假设我有以下组件:

<cfcomponent displayname="User">
    <cfset variables.firstName = "first" />
</cfcomponent>

Which I wanted to use as a return to a remote method being consumed via SOAP. I would need to <cfproperty> tags for each variable I wanted to encapsulate in the returned object, in order for that object to be included in the WSDL document as a complex type. Therefore, the component from above would have to be:

我希望将其用作返回通过SOAP使用的远程方法。我需要为我想要封装在返回对象中的每个变量的 标记,以便将该对象作为复杂类型包含在WSDL文档中。因此,上面的组件必须是:

<cfcomponent displayname="User">
    <cfproperty name="firstName" type="string" />
    <cfset variables.firstName = "first" />
</cfcomponent>

#1


CFPROPERTY is only useful for providing metadata for a component. The only time I ever use them is when creating a component for a Web Service, when they're required.

CFPROPERTY仅对提供组件的元数据有用。我唯一使用它们的时候是在需要时为Web服务创建组件。

Here's a TechNote which discusses CFPROPERTY a bit further: http://kb2.adobe.com/cps/191/tn_19169.html

这是一个技术说明,它进一步讨论了CFPROPERTY:http://kb2.adobe.com/cps/191/tn_19169.html

The variables scope is "protected" and only available within the component. The "this" scope variables are public properties. And, of course, any variable declared with the "var" keyword is private to that method.

变量范围是“受保护的”,仅在组件中可用。 “this”范围变量是公共属性。当然,使用“var”关键字声明的任何变量都是该方法的私有变量。

Here's some more on component scopes: http://www.hemtalreja.com/?p=94

以下是有关组件范围的更多信息:http://www.hemtalreja.com/?p = 94

#2


Note: cfproperty tag does NOT defined variables.

注意:cfproperty标记没有定义变量。

However, it is helpful when you use CFC Explorer (browse to the CFC directly), so that you can see the properties of the CFC object.

但是,在使用CFC Explorer(直接浏览到CFC)时很有用,这样您就可以看到CFC对象的属性。

FYI... cfproperty will be much more useful in CF9. See: ORM - Rethinking ColdFusion Database Integration

仅供参考... cfproperty在CF9中会更有用。请参阅:ORM - 重新思考ColdFusion数据库集成

#3


cfproperty is useful when using custom objects in remote methods. For example, suppose I had the following component:

在远程方法中使用自定义对象时,cfproperty非常有用。例如,假设我有以下组件:

<cfcomponent displayname="User">
    <cfset variables.firstName = "first" />
</cfcomponent>

Which I wanted to use as a return to a remote method being consumed via SOAP. I would need to <cfproperty> tags for each variable I wanted to encapsulate in the returned object, in order for that object to be included in the WSDL document as a complex type. Therefore, the component from above would have to be:

我希望将其用作返回通过SOAP使用的远程方法。我需要为我想要封装在返回对象中的每个变量的 标记,以便将该对象作为复杂类型包含在WSDL文档中。因此,上面的组件必须是:

<cfcomponent displayname="User">
    <cfproperty name="firstName" type="string" />
    <cfset variables.firstName = "first" />
</cfcomponent>