Serialization of inherited CFC properties doesn't work
I didn't find anything on this problem, though it's hard for me to believe that it hasn't been encountered and addressed somewhere.
The title says it -- though the biggest problem is that the serialization fails when trying to send over the wire to a CF backend. I have heard that with FlashRemoting there is a workaround, but don't know what to do in CF. Here are some files that demonstrate it.
application.cfm
component {
this.sessionmanagement = 'true';
this.sessionTimeout = createTimeSpan(0,2,0,0);
this.name = "SE";
}
Component files (some settings are hold overs from the ORM-enabled app they come from)
Job.cfc:
component
entityname="Job"
persistent="false"
table="tbl_job"
output="false"
accessors="true"
discriminatorcolumn="entity_type"
{
/**
* @column id
* @fieldtype id
* @10825876 increment
* @3514369 true
* @Setter false
*/
property int id;
// discriminator column
/**
* @10986680 false
* @7605746 false
*/
property entity_type;
// **** Common Properties
/**
* @column name
* @length 255
*/
property string name;
/**
* @column description
* @length 400
*/
property string description;
/**
* @displayname init
* @description init method
* @8071592 false
*/
public any function init() {
return this;
}
}
Campaign.cfc:
component
entityname="Campaign"
persistent="false"
table="tbl_job"
output="false"
accessors="true"
discriminatorvalue="campaign"
extends="Job" {
/**
* @column camp_prop
* @length 255
*/
property string camp_prop;
}
Index.cfm:
<cfscript>
c = new serializationError.Campaign();
writeoutput( "New, empty campaign: ");
writedump( c );
c.setName("Campaign name");
c.setDescription("This is my description");
writeoutput( "<br />Campaign with inherited properties set which don't show up in the dump: ");
writedump( c );
writeoutput("<br />Here is the value of 'name', an inherited property: '" & c.getName() & "'<br />");
writeoutput( "<br /><br />Here is the serialized version of the object (which shows up empty): <br />" & serializeJSON( c ) );
c.setcamp_prop("Here is a property in the campaign");
writeoutput("<br /><br />Here is dump after a non-inherited property has been set: ");
writedump( c );
writeoutput( "<br />Here the serialized version (which has the non-inherited value, but no inherited values):<br /> " & serializeJSON( c ) );
</cfscript>
