If you downloaded the new version of ColdFusion you may have found that some things have changed from the public beta you were using. The first that you need to know about is implicit getters and setters are not created by default. If you create a component with some properties it does not automtically create them for you. To accomplish this you just need to add an attribute to your component. This of course is not the case if you are using ORM. If you set the component to persistent it will know that you need getters and setters created for you properties.

#1 by Ben Nadel on 10/6/09 - 9:53 AM
#2 by Dan Vega on 10/6/09 - 9:55 AM
#3 by Ben Nadel on 10/6/09 - 9:58 AM
#4 by Dan Vega on 10/6/09 - 10:00 AM
#5 by Ben Nadel on 10/6/09 - 10:04 AM
... actually, what probably would break is using OnMissingMethod() to auto-wire Get/Set property values... so in that case, I guess it would be bad :)
#6 by Dan Vega on 10/6/09 - 10:07 AM
property lastname
property fullname
If you have a setFullName() that builds the first name from the first + last the implicit setFullName() would not accomplish the same thing.
First thing that I thought of but I am sure other scenarios would be screwy. I don't mind the accessors=true.
#7 by Ben Nadel on 10/6/09 - 10:13 AM
I am OK with the accessors="true" as well; just seemed like an arbitrary change.
#8 by Dan Vega on 10/6/09 - 10:15 AM
#9 by Ben Nadel on 10/6/09 - 10:19 AM
#10 by John Whish on 10/6/09 - 10:22 AM
#11 by Ben Nadel on 10/6/09 - 10:23 AM
Ahh, ok that would make sense then.
#12 by John Whish on 10/6/09 - 10:31 AM
#13 by Tony Nelson on 10/6/09 - 10:38 AM
#14 by Rupesh Kumar on 10/6/09 - 11:13 AM
#15 by Brad Wood on 10/6/09 - 12:10 PM
#16 by Dan Vega on 10/6/09 - 12:21 PM
#17 by Mark Mandel on 10/6/09 - 5:05 PM
Having weird arbitrary rules for when implicit getter/setters exist only cause to confuse the issue further. A simple flag for being able to turn it off makes life easy for everyone, as then it is very clear exactly what is going on.
@Dan good post!
#18 by Brad Wood on 10/6/09 - 6:14 PM
I can understand us wanting the logic to be consistent and simple, though I would call the terms "weird" and "arbitrary" a bit of a stretch.
I was building off Tony's desire that implicit gets and sets should be a core part of the language as often as possible and not have to be enabled to encourage their adoption. Therefore, the most appropriate solution would seem to be finding the 80/20 ratio. Which default would be the most common and which one would require more people to retrofit their code?
ColdFusion 9 has still broken parts of some frameworks with its new functions so obviously Adobe weighed the trade off of 100% backwards compatibility with what made sense and would affect the smallest amount of people.
Back to the discussion of what the default value should have been for implicit getters and setters; I personally rarely use onMissingMethod so I would have to make no changes at all. However the 2 of us are in no way a representation of the CF programming community as a whole. Honestly I don't even know if Adobe themselves has statistics of which default would have affected the greater percentage of people without having access to every CF codebase. It seems they went with the safest method (which is understandable), but it by no means is the method guaranteed require the smallest amount of refactoring upon release.
#19 by Matthew Lesko on 10/7/09 - 12:36 PM
#20 by Jim Planter on 12/17/09 - 9:07 AM
Say I have accessors="true" set and my component has an explicit setter function defined for firstName.
Is there no way from within the explicit setter to change the value of the property that ColdFusion maintains through the implicit setters?
<cfdump var="#person#" /> shows the firstName property value but I can not find a way to manipulate it without calling an implicit setter.
I've tried:
* variables.properties.firstName
* this.properties.firstName
* Returning the value to set to firstName
Anyone know how to do this?
#21 by Dan Vega on 12/17/09 - 9:50 AM
/**
* @accessors true
*/
component {
property firstname;
property lastname;
property email;
/**
* @setter false
*/
property password;
public User function init(){
return this;
}
public void function setPassword(String password){
variables.password = hash(arguments.password);
}
}
#22 by Jim Planter on 12/17/09 - 10:06 AM
* variables.firstName
The collision of property and functions names in the variables scope gets a little funky. A function of the same name can only be accessed through "this", so the access has to be public.
#23 by Jim Planter on 12/17/09 - 10:17 AM
Certainly isn't very intuitive.
Man I wish the implicit setters would return "this" rather than void, so we could do method chaining: person.setFirstName("Jim").setLastName("Planter");
I never got why they would engineer it this way.
Also, the core functions that return boolean on success rather than the object being acted on really feels like a waste too. (i.e. structAppend() ). Ah well I'm getting off topic.