Hi,
Actually it seems you’re running in to a fairly common gotcha: addItem() does not accept an Item but an Object that is to be the new item’s id.
I.e. you can not ‘force-feed’ Items to the IndexedContainer, it want’s to create it’s own Items.
This:
getHostList().getContainerDataSource().addItem( getHostForm().getItemDataSource() );
should be something like:
Object id = getHostList().getContainerDataSource().addItem(); // this will generate an id, you can also give one
Item newItem = getHostList().getContainerDataSource().getItem(id);
// [...]
fill the item
In your example, this would require copying the stuff from the HostForm item to the HostList item, which is a bit odd, with this information you might want to rewrite a litte. Also, creating a new Container just to get a new Item is never a good idea (as in HostForm).
One solution would be to create a separate bean (POJO) for your actual data, and use BeanItem and BeanItemContainer to bind it to the Form and Table respectively.
// pseudocode
// e.g. for the form:
form.setsetItemDataSource(new BeanItem(mypojo));
// HostContainer extends BeanItemContainer:
getHostList().getContainerDataSource().addBean(mypojo);
Did this make any sense?
Best Regards,
Marc