remove items from table

Hi,
I have a table full of beans. Pressing a button, I want to remove all rows having a particular value in a property of the row.
If I iterate on the container, I can’t remove any element because getItemIds() returns an unmodifiable collection and removing an item throws ConcurrentModificationException:

Iterator<MyBean> i = (Iterator<MyBean>) myTable.getItemIds().iterator();
while ( i.hasNext()) {
	MyBean ib = i.next();
	if (ib.isToBeRemoved()) 
		myTable.getItemIds().remove(ib); //java.util.ConcurrentModificationException
}

Then, how can I remove rows from the table?

Thank you, Francesco


Iterator<MyBean> i = (Iterator<MyBean>) myTable.getItemIds().iterator();
List<MyBean> toBeRemvoed = new ArrayList<MyBean>();
while ( i.hasNext()) {
    MyBean ib = i.next();
    if (ib.isToBeRemoved()) {
       toBeRemoved.add(ib);
    }
}
myTable.getItemIds().removeAll(toBeRemvoed);