0

I'm trying to get a CFC (webCFC) with a remote function to return an instance of a different CFC (objCFC).

Here are the CFCs:

#webCFC
component { 
    remote function displayCFC(version=1) {
        if(version==1) {
            return new baseCFC();
        } else {
            return new objCFC();
        }
     }
 }

#baseCFC
component 
    accessors="true"
    persistent="true"
{
    property name="name" default="pete";    
}

#objCFC
component 
    extends="baseCFC"
    persistent="true"
    accessors="true"
{
    property name="age" default="30";
}

If I call this URL: /webCFC.cfc?method=displayCFC&returnFormat=json, I get this response:

{
"name" : "pete"
}

which is fine. If I call this URL: /webCFC.cfc?method=displayCFC&returnFormat=json&version=2, then the response is missing the property from baseCFC

{
"age" : 30
}

I would expect the response to look like this:

{
"name" : "pete",
"age" : 30
}

I know that I can use the setName() and getName() functions on objCFC, it is definatly extending baseCFC but the extended properties don't show if I access the CFC through the browser.

Is it possible to get this to work?

Pete
  • 4,542
  • 9
  • 43
  • 76

1 Answers1

0

This could be related to the seralizejson bug (not sure when will it ever be bug free).

A workaround would be to implement your own getMemento() or toJSON() method that returns all the desired properties in a struct. Then serializeJSON that struct instead.

Henry
  • 32,689
  • 19
  • 120
  • 221
  • I did wonder if it was to do with JSON, but if I just do a writeDump in the page, it doesn't show the properties there either. But you're right, if this is a bug then I'll have to loop over the properties and output them manually – Pete Sep 06 '12 at 06:50