Copy table row

Hi,

What I would like to do is to select an item in my table, the press my “Copy” button and it would take a copy of the selected row and insert it back into the table as the next row after the selected. I tried this

@Override
public void buttonClick(final ClickEvent event) {
Object itemId = transactionTable.getValue();
if (itemId != null) {
itemId = transactionTable.addItemAfter(itemId);
if (itemId != null) {
transactionTable.select(itemId);
}
  }
}

but im getting UnsupportedOperationException from the addItemAfter() method.

Anyone got a pointer on how I could do this?

Ok, I figured it out myself, its the container data source I needed to change, not the table - here is how, if someone is interested

            @Override
            public void buttonClick(final ClickEvent event) {
                Object itemId = transactionTable.getValue();
                if (itemId != null) {
                    final BeanItem<TransactionBean> beanItem = transactionBeans.getItem(itemId); 

                    transaction = beanItem.getBean().getTransaction();

                    itemId = transactionBeans.addItemAfter(itemId, new TransactionBean(transaction));
                    transactionTable.refreshRowCache();
                    if (itemId != null) {
                        transactionTable.select(itemId);
                    }
                }
            }