Skip to main content
Known Participant
November 3, 2009
Question

Sending Typed Objects to Flex ?

  • November 3, 2009
  • 1 reply
  • 971 views

Hi,

i'm tried many things now... On my Localhost (Coldfusion9) it's all working correctly. But on our live-Server (only Coldfusion 😎 it doens't...

I  am develop with Coldfusionbuilder...

My Script is really as simple as possible:

<cfcomponent >
        <cfproperty name="firstname" type="string" >
</cfcomponent>

<cfcomponent extends="UserVO"  >
        <cfproperty name="lastname" type="string" >
</cfcomponent>

<cfcomponent>
    <cffunction name="getUser" access="remote" displayname="getUser" output="false" returntype="vo.ComplexUserVO">
   
        <cfset myUser=createObject("component", "vo.ComplexUserVO" ) >
   
        <cfset myUser.firstname     = "Nico" >
        <cfset myUser.lastname     = "Barelmann" >

        <cfreturn #myUser#>
   
    </cffunction>
</cfcomponent>

So i have 2 objects with one property in each of them. If i return once the username or the password (itself as a string) it will "arrive" in Flex correctly... But if i give it a concret returntype (that would be nice) Flex says that the "firstname" attribute is null. (lastname is correct)

Problem1: If i set a returntype (in Cf) i've got an error, that the returntype Component can't be found

Provlem2: if i do not set a returntype, just the lastname arrive @ flex...

Any Ideas? Like i said before, on my localmachine both, firstname and lastname, arrive correctly. So i think that the issue lies somewhere between cf8 & 9...

thanks for any help!

Greets, Nico

Ps:

A Coldfusion-Page in the same directory with that code:

<cfset myUser=createObject("component", "vo.COmplexUserVO" ) >

    <cfset myUser.firstname = "nico" >
    <cfset myUser.lastname = "Barelmann" >

    <cfoutput >
    #myUser.firstname#
    </cfoutput>

.... The Output i correct. (Either firstname or lastname)

This topic has been closed for replies.

1 reply

Participant
November 4, 2009

Inheritance in ColdFusion doesn't work with the AMF serializer unless you take an extra step.  For example, in your ComplexUserVO you have two properties: firstname and lastname.  However, the AMF serializer will analyze the CFC and only see lastname.  Because of this, you have to include the <cfproperty /> declaration for the parent class as well.  In this case, the following CFC would work:

<cfcomponent extends="UserVO">
        <cfproperty name="firstname" type="string" >
        <cfproperty name="lastname" type="string" >
</cfcomponent>

This seems repetitive, but it is required to get the correct values returned to Flex.

maeldanusAuthor
Known Participant
November 4, 2009

Hi David,

thanks for the quick-answer!

That step seems to be realy stupid. I mean, coldfusion want to be THE main-Serverside-technology for RIA's driven by the flash-plattform. weird :|

To the code:

So i can kill the "extends UserVO" thing because it doesn't make any sense in that case ?!

One big question: On my localmashine IT IS working, without any problem Is that thing differint in Coldfusion 9 ?

Greets, Nico

Participant
November 4, 2009

It may very well be different in ColdFusion 9 - I actually haven't tried that.  Because of this limitation, I usually avoid using inheritance with Value Objects.  Don't get me wrong - there can be perfectly valid reasons to do this.  If you do have a valid reason, then just adding the extra cfproperty tags will solve the problem.