Hello all,

If someone can figure this out, it'd make my day. Here's what we'd like to do:

We have an object A, which is an ActionScript object created on the
client. In our application, we have at least two references to object
A. Using one of the references, we send object A back to the middle
tier, where it is serialized into a Java object, some operations are
done (persistence related, like inserting into a DB and assigning a
primary key), and object A is sent back to the client as object B,
possibly with updates. When we receive it, we'd like to replace object
A with object B. That is, we'd like to have all the former references
to object A now point to object B. Since we only know about one of the
references to object A, we want to use that reference to get all the
references to object A and update them accordingly. So, in made up
code, that would look something like this:

function updateReferences( refToA : Object, refToB : Object) {
         var allRefsToA  : Array = refToA.getAllReferencesToObject(); 
// made-up part
         for(var i = 0; i < allRefsToA.length; i++) {
               allRefsToA[i] = refToB;
         }
}

Does that make sense? Is there anything which we can do to simulate
the imaginary "getAllReferencesToObject" function?

-------------------------------------------------------------------------------

(The rest is just explanation as to why we're not taking an
alternative approach)

The reason why we want to do this, instead of simply copy all the
attributes out of object B and into object A, is because the object
heirarchy contains internal references back to the object which are
necessary for our persistence layer to figure our the proper
relationships. That is, our object A represents the parent in a
parent-child relationship and each child contains a references back to
the parent. Here's an ASCII representation (omitting the
non-problematic attributes of A):

 A
  |
anArrayOfAChildren
|         |         |
cA1   cA2   cA3
|         |         |
A       A        A

And object B is essentially a copy of this object model, but with B's
instead of A's. What we have done in the past (and recently discovered
to be incorrect) is something like

function mergePersistenceChanges ( refToA : Object, refToB : Object) {
      for(var i in refToB) {
            refToA[i] = refToB[i];
      }
}

Which produces mostly what we want (all of the updated information is
copied correctly), but in the case of our back-references, it produces
an incorrect result like this:

 A
  |
anArrayOfBChildren
|         |         |
cB1  cB2    cB3
|         |         |
B       B        B

This causes future updates of attributes in object A not to be
reflected in the childrean objects .... which is our problem. Is
someone is able to suggest a solution, or a way to implement the
proposed solution above? Thanks so much.

Jim


------------------------ Yahoo! Groups Sponsor --------------------~--> 
AIDS in India: A "lurking bomb." Click and help stop AIDS now.
http://us.click.yahoo.com/9QUssC/lzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
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