What is the difference between cfproperty variable and scope variable in coldfusion?

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

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

Thank you, thank you!

+4
source share
3 answers

CFPROPERTY is only useful for providing metadata for a component. The only time I use them is when you create a component for a web service.

Here's TechNote, which discusses CFPROPERTY in more detail: http://kb2.adobe.com/cps/191/tn_19169.html

The variable area is "protected" and is available only in the component. The scope variables "this" are publicly available. And, of course, any variable declared with the keyword "var" is private to this method.

Here are a few more component areas: http://www.hemtalreja.com/?p=94

+12
source

Note: the cfproperty tag has NOT defined variables.

However, this is useful when you use CFC Explorer (directly for direct access to CFC) so that you can see the properties of the CFC object.

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

+6
source

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

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

Which I wanted to use as a return to the remote method consumed through SOAP. I would need <cfproperty> tags for each variable that I wanted to encapsulate in the returned object, so that this object was included in the WSDL document as a complex type. Therefore, the component on top should be:

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

All Articles