Flash Remoting MX has always had the following rules for data type
translation:

java.lang.reflect.Array -> AMF Strict Array -> ActionScript Array
java.util.Collection -> AMF Strict Array -> ActionScript Array
java.util.Map -> AMF ECMA Array -> ActionScript Array with Associative
Keys
flashgateway.io.ASObject -> AMF Object -> ActionScript Object

...these rules pre-dates ActionScript 2.0 (see later) and each product
that essentially OEMs Flash Remoting technology is subject to them.

I believe ColdFusion structs are seen by Flash Remoting as java.util.Map
instances, so that means they're going to the client as ECMA Arrays, not
Objects. Thankfully (for now) you can use the following ActionScript
syntax to get named keys from arrays as well as object properties:

public function myResultHander(result:Object)
{
        var sessionId = result["SESSIONID"];
        var userId = result["USERID"];
        var valid = result["TRUE"];
}

I would trust the data type information from the Network Monitor more
than the NetConnection Debugger as the NCD is an old AS1 tool that is
not without its bugs (especially with data type handling). The issue
with the Network Monitor reporting the Array length as 0 is probably
because the result doesn't contain any elements based on ordinal keys
(i.e. as would appear in a Strict Array with indexes 0, 1, 2 etc), only
string-based "associative" keys (like SESSIONID, USERID, TRUE). This is
a bug.

With this issue of the Struct result being an sent as an "Array" but
without much of the Array API being useful, and also due to the
increasingly complex and strongly typed data structures being persued by
most Flex applications, I would urge you to file two enhancement
requests - 1.) for Flex to allow generic Maps to come back as Objects
(would have to be configurable for backwards compatibility), 2.) for
ColdFusion to provide an update to allow the same thing. I'm not sure if
you can vote for enhancement requests - but if the Flex and CF
communities push I'm sure someone will hear!

Oh, finally, as for the result being claimed to be undefined - how did
you make this test? Did you do something like this:

public function myResultHander(result:Object)
{
        if (result != undefined)
      {
           //process result...
      } 
}

Alas not even Flash Remoting is without its constraints - this time
remoting itself is subject to bugs of the Flash Player where by
deserialized objects can answer "true" to a test for undefined. To work
around this try the strict not-equals operator (i.e. !==) so that
casting is not attempted before the comparison is made.

public function myResultHander(result:Object)
{
        if (result !== undefined)
      {
           //process result...
      } 
}

(I believe this may also be the root of the issue in the NCD for types
registered with Object.registerClass not displaying - they are reported
as undefined too)

Pete
 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tim Blair
Sent: Tuesday, April 26, 2005 12:48 PM
To: FlexCoders
Subject: [flexcoders] Disappearing struct from CFC using RemoteObject


Hello,

I'm slowly going crazy here.  I'm trying to make a simple RemoteObject
call to a ColdFusion CFC using Flash Remoting.  Nothing exciting -- pass
a couple of vars, get a structure containing user data back.

Whenever I try and return a type of struct (and only struct, as far as I
can see) from the CFC, things go a little strange and I don't get the
results I expect back (an object containing thye keys: sessionid, userid
and valid).  In the net conection debugger I get back the following,
which looks correct to me:

DebugId: 0
EventType: "Result"
MovieUrl: "http://localhost:8888/flex/test.mxml.swf";
Protocol: "http"
Source: "Client"
Time: 1114533397451
Date (object #1)
....."Tue Apr 26 17:36:37 GMT+0100 2005"
Result (object #2)
.....SESSIONID: "7F3D91BB-8A11-29EE-1B5963898741A372"
.....USERID: 1
.....VALID: "TRUE"

However, the network monitor only shows this:

[array] : 
    length[Number] : 0

>From some further poking, when checking the return data, event.result is
undefined;  the private member data __result *does* contain the correct
data, but I can't access this using event.result.

Does anyone have an idea what's going on here?

Thanks,

Tim.

--
-------------------------------------------------------
Badpen Tech - CF and web-tech: http://tech.badpen.com/
-------------------------------------------------------
    RAWNET LTD - independent digital media agency
    "We are big, we are funny and we are clever!"
     New site launched at http://www.rawnet.com/
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
-------------------------------------------------------


 
Yahoo! Groups Links



 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to