This content has been marked as final. Show 3 replies
Your example is a little complicated so forgive me if I have the wrong idea. Also, although I work with Java programmers on Flex projects, I know next to nothing about Java, so Hashmap is a blurry concept for me.
The way I understand it is that you get one object A from the Java side, which has one hashmap wich contains one or more objects B which each contain one object C.
In that case I would change your myMap variable to an ArrayCollection instead of an Object. In fact, if it's possible, I wouldn't use the A object at all, since all it contains is the Hashmap. Simply casting the result you get from java into an arraycollection should suffice, there's no need to loop over the result. An arraycollection will also be much handier when working with Datagrids.
Again to put the C object of each B object into a Datagrid, you don't need to loop over the arrayCollection. Simply put the arraycollection as dataprovider to your datagrid and in the column use myC as datafield. I often notice that Java developers tend to use Actionscript far to often when there are components that do the difficult work for you.
Your second problem I don't fully understand. If you create a new instance of B then of course that instance will have default values, but it shouldn't affect any other instances.
You got the general idea but you missed some important points. I can't use ArrayCollection because java.util.HashMap can't be converted into one, it converts to Object. Think of HashMap as a Dictionary, a key with a value, so it maps to Object.
I did a simple example for this, actually A, B and C have more properties, i just simplified it for this example.
You are right about not having sense, i am not creating a new B object, i tried to use it like this " if (is B) ", by doing that you are using an instance of B, that's when the properties of object C are being reset. The properties of B (id and name) aren't being reset, but the myC property, which is a C object, is the one being reset.
I realized that whenever i use a B instance, that is inside an if condition, or if i create a new B, then the C objects of the map are being reset, as if when using a B instance the Flash Player tried to cast the C objects automatically but instead it is reseting them.
I am trying to put up a quick functional example of this behavior hoping someone can help me out
Ok i fixed it, like i said my app was a more complicated scenario so here's what happened:
The C object is the superclass of D and E, and the Java service puts objects D or E inside the myC property of the B object, since myC is of type C and C is the super class of D and E then this works.
The problem is that in Flex the C object inside B is actually a D or an E object, i just had to use an instance of D and E somewhere in the code so the Flash Player included those classes.
Anyways, i know this is all complicated but the good news is that it works now