2 Replies Latest reply on Feb 13, 2008 12:21 PM by ntsiii

    Array of VO's

    kruse Level 1
      I have got a VO called personVO that have got firstname and lastname.

      Then I have an array that contains the personVO.

      In my interface it is then possible to select a personVO.
      The selected personVO would I like to have in the variable selectedPerson.

      How do I do that?

      First I thought about copying the selected personVO into selectedPerson. But I do not want to have another copy of the values because they are already in the array.

      Then I thought about making the selectedPerson to some kind of pointer, pointing into the array.
      But I do not want the selectedPerson to have an index value to the selected personVO. I want the selectedPerson to point directly to the VO.
      I would be able to call the selected persons firstname like this selectedPerson.firstname.

      Is this possible?
        • 1. Re: Array of VO's
          Ratsnackbar Level 2
          You might want to think about using an ArrayCollection rather then an Array. You can then implement Bookmarking and Cursors to get the effects you want directly off the ArrayCollection. It also has added value in that any control that makes use of the arraycollection as it's dataprovider auto update as items in the array are modified.

          -Joe
          • 2. Re: Array of VO's
            ntsiii Level 3
            yes, use arrayCollection if you plan to programatically update the VO, as you clearly plan.

            In almost all cases, assigning a complex object to a variable creates a reference/pointer to the original object. So if you do:
            var voSelectedPerson:personVO = acPersons.getitemAt(0);
            you have a reference into the item in the collection not a copy.
            So,
            voSelectedPreson.firstname = "joe";
            puts that value into the correct item in the collection.

            Tracy