Hi guys , i have a problem which has kept me banging my head against a brick wall all day. I am using a collection to store objects
so later i can display them in a rich:dataTable component.
I have an iterator in a for loop so as to initialize an object (detalle). Once an object is initialized, it gets stored in a collection
using the add(Object) method , problem is , the whole collection is overwritten by the most recent object inserted by the add() method.
It goes something like this:
object detalle1 is initialized
object detalle1 is added to a collection
collection's size is one and holds object detalle1
object detalle2 is initialized
object detalle2 overwrites the first slot
object detalle2 is added to an auxiliary collection
Now instead of having Collection: detalle1 , detalle2 , i have a duplicate of object detalle2 and the first object is overwritten.
collection's size is two and holds detalle2 , detalle2 (detalle1 has been overwritten)
If I continue with more iterations , the last object is added at the end , but overwrites all the rest of the objects in the collection.So i end
up with the last object all over the collection.
I tried advancing the pointer with Collection.iterator.next() to no avail. This keeps happening and I dont know what is going on.