Highlighted

Java - Actionscript objects not serializing

thehair77

05-11-2008

Hi



I am having trouble serializing some objects from Java to
Flex.



On 90% of my objects the mapping is fine, but on 10% the
mapping can not be found so flex defaults the object type to
Object, rather then the ActionScript type that has been defined.



All of the Java Objects to be mapped have a public no
argument constructor, and a getter and setter for each of the
properties to be mapped.



An example of two object, one where the mapping is found and
one where it is not:



package model

{


[RemoteClass(alias="org.sdmx.infomodel.keyfamily.impl.DimensionImpl")]


public class Dimension extends Component

{

public var codeList:Codelist;



}

}



This maps ok, in debug mode I can see this is model.Dimension



package model

{


[RemoteClass(alias="org.sdmx.infomodel.keyfamily.impl.FrequencyDimensionImpl")]


public class FrequencyDimension extends Dimension

{



}

}



Mapping can not be found, in debug this maps to Object
(@MemRef) all of the Objects attributes properties come down the
wire, but the Object type is not found.



The Java class for FrequencyDimension is very simple, all it
does is have a default constructor and extend Dimension.



There does not seem to be any relationship between the
classes that don’t map, some extend already mapped classes
some do not, sometimes the bad mapping is in objects held in a
List, sometimes it isn’t. Actually, there is one
relationship, I think of the classes that don't map, they are the
latest classes written, and I wonder if this is a compiler issue,
not exporting the classes properly?



Can anyone help?



Replies

Highlighted

thehair77

05-11-2008

Found the answer.



This seems to be because none of my code was explicitly
instantiating or using the type FrequencyDimension, so I guess it
was not compiled into the swf. This seems to be by design, although
IMHO this is bad design as it causes confusion when working with
DataServces and it forces unnecessary code to be written.



Highlighted

Karl_Sigiscar_1

18-11-2008



Yes indeed. It is not compiled into the swf unless it is
referenced or cast.



Also, be careful to the variable names in Java like
firstName.



During deserialization, ActionScript might expect a different
spelling than firstName because of the mix between lowercase and
uppercase.