Thanks, Seth. I'd read the article, but your e-mail clarifies the
issues. I've looked over our usage and I think we're safe for now, but
this is sort of a time bomb, and it might make sense to fall back to
just Strings. The only alternative I see is ensuring to use .equals()
everywhere, which is tricky, especially when dealing with collections
and other data structures (since they'll already be using the standard
'==' equality checks).
-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: Seth Hodgson <shodg...@adobe.com>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com <flexcoders@yahoogroups.com>
Subject: RE: [flexcoders] Java enum in Flex3
Date: Wed, 4 Feb 2009 21:14:29 -0800

Hi Maciek,

I don't know anything about Granite Data Services but a quick google
search returns this: http://www.graniteds.org/jira/browse/GDS-228

The reason why they're getting multiple instances of their "enum" AS
classes during deserialization is layed out in the post I linked to
below - without a readResolve() hook in the Player there's no way to
support reading singletons out of the AMF stream.

This means that you have potentially many duplicate instances of each
enum value floating around in the AVM. It looks like they've defined an
equals() method as an attempt to work around this, but while that's a
standard method defined on Java's base Object class there is no equals()
method defined in the core ECMAScript/ActionScript libraries. If I were
using client side enums in ActionScript, I'd expect simple equality
checks to work correctly and they won't with this approach.

Each of these classes will also add a bit to your swf size, but that's a
minor concern unless you're using tons of enums :)

I don't know what other value these classes may provide, perhaps some
help with data validation, but be careful in your code anywhere you're
expecting them to actually be singletons because they generally won't
be.

Best,
Seth

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Maciek Sakrejda
Sent: Wednesday, February 04, 2009 5:38 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Java enum in Flex3

Interesting. Any thoughts on Granite Data Services' approach? There is a
custom externalization process for Java Enum objects, and a granite Enum
class in ActionScript that all your (generated) Enums extend. The enum
class takes care of reading/writing. The writeExternal() method just
writes the name of the Enum; readExternal() tries to find the name of
the object in the constants defined by the Enum. The RemoteAlias
metadata is set up as for a standard Java class.

Are we asking for trouble in using this method? Is there something
inherently dangerous here?
-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: Seth Hodgson <shodg...@adobe.com>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com <flexcoders@yahoogroups.com>
Subject: RE: [flexcoders] Java enum in Flex3
Date: Wed, 4 Feb 2009 16:20:33 -0800

BlazeDS and LCDS roundtrip Java enums to the client and back as Strings.
That's the only good option at present, and here's an in-depth
explanation: http://greetingsfromoakland.blogspot.com/2009/02/enums.html

Best,
Seth

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of sunmoorthy1
Sent: Monday, December 29, 2008 1:18 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Java enum in Flex3

How to convert java enum values into Flex3 object.
Any one went thru this problem?
Please give your experties?

Sundar 







Reply via email to