|
|
|
[
Permlink
| « Hide
]
Trevor Baker - [03/25/08 03:09 PM ]
to Seth for review/consideration
The issue with this is that you'll get the expected ActionScript Object on the client, but if you send it back to the server you won't end up with a Map<Integer, String> or whatever you started out with. If that's not a concern it may be worth considering.
For now, you can register your own custom MapProxy with the PropertyProxyRegistry during server startup (from a BootstrapService impl for instance). We are only going one way with the HashMap, so we have not had the problem the other way. So you are saying that the only Map you can use is Map<String,Object>(without writing a custom proxy)? We can certainly live with this. However, I think the MapProxy should handle non String keys in a map better. Currently if I have an <Integer,Object>, when I get the values in actionscript, the keys are there but the values are missing. It makes you first troubleshoot problems with your values and those objects rather than your keys. I would expect one of the following resolutions instead:
1. In MapProxy, all of the keys for a map passed in would be converted to strings, thus allowing the values to be found correctly later. As you said, this would be inconsistent if someone went from AS to Java(but this may still be better than the current output). 2. flex.messaging.io.PropertyProxy would make parameters for propertyName type Object instead of String. A toString would be done on the propertyName further down the line after the values are retrieved. 3. MapProxy would do an instanceOf on the keys and if is not type String would throw an error(MapProxy would not accept a Map with non String keys). We'll update MapProxy to not toString() entries in the the propertiesNames list and use the original Object key to look up the value during serialization, but we'll still toString() when looking for potential concrete/declared bean properties (for support of strongly typed subtypes that implement Map).
That will resolve your issue, but I still have a concern that folks will expect this sort of thing to roundtrip correctly. Unfortunately, the flash.utils.Dictionary type is not natively supported by AMF so Maps on the server must be serialized to anonymous ActionScript Objects on the client. The API for Object is conceptually Map<String, Object>, so there's no way to ship something like a Map<Integer, Object> from the client back to the server apart from implementing custom types in ActionScript and Java that use IExternalizable to make this work. So, when sending data to Flash, the recommended approach remains to use strongly typed objects on both ends or to use a Map<String, Object> on the server which is symmetric to an anonymous ActionScript Object. Fixing and checking this in is lower down my current stack right now, but I'll get to it :) We have a public Java API that we have exposed via BlazeDS to a Flex-based client. This public Java API uses maps fairly extensively. We also use typed identifiers in our API, as it is a best practice to use typed identifiers rather than Strings. We REALLY need to get this fixed as soon as possible. So, I'll keep an eye on it!
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||