0
votes

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?

1

1 Answers

0
votes

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.