-
1. Re: What's the point in using CFPROPERTY for my Beans?
Carl Von Stetten Dec 23, 2013 8:25 AM (in response to Aegis Kleais)Aegis,
Could you post a minimal sample of your CFC code that can be tested?
-Carl
-
2. Re: What's the point in using CFPROPERTY for my Beans?
Aegis Kleais Dec 23, 2013 2:11 PM (in response to Carl Von Stetten)<cfcomponent>
<cfset variables.my = {} />
<cfset variables.my.name = '' />
<cffunction access="public" returntype="UserBean" name="init" output="false" hint="I return a User">
<cfargument required="false" type="string" name="name" hint="I am the user name" />
<cfset setName( arguments.name ) />
<cfreturn this />
</cffunction>
<cffunction access="private" returntype="boolean" name="init" output="false" hint="I set the name property">
<cfargument required="true" type="string" name="name" hint="I am the user name" />
<cfset variables.my.name = arguments.name />
<cfreturn true />
</cffunction>
</cfcomponent>
So if you call it like:
<cfset userObject = new UserBean( name="Aegis" ) /><cfdump var="#userObject#" />
You will see a dump of the object, and you can expand into the methods, but no properties are shown.
BUT if you add the following line immediately after the opening <cfcomponent> tag:
<cfproperty required="true" type="string" name="name" hint="I am the user Name" />
And then leave ALL the other code alone, dumping the UserObject results in an object with a PROPERTIES sub structure (that is inaccessible via syntax like UserObject.Properties...)
But in all my testing, modifying the UserObject changes the expected variables with or without properties, you just don't get that structure in the dump if you omit the <cfproperty> tag.
-
3. Re: What's the point in using CFPROPERTY for my Beans?
Carl Von Stetten Dec 23, 2013 2:22 PM (in response to Aegis Kleais)Is that just a typo in the post, or is your private method also called "init"? Should it be "SetName"? Seems like that could be a problem.
-Carl
-
4. Re: What's the point in using CFPROPERTY for my Beans?
Aegis Kleais Dec 23, 2013 3:34 PM (in response to Carl Von Stetten)It's a typo. I hand-coded the above, cutting down on my commenting and spacing in order to keep it minimal.



