How to add generatedColumn to BeanItemContainer in Table?

Hi,

I have a Table that has a generatedColumn to modify table items.
I have introduced a BeanItemContainer for the table data, but now I cannot add the generated Columns anymore:


com.vaadin.server.ServiceException: java.lang.UnsupportedOperationException: Use addNestedContainerProperty(String) to add container properties to a BeanItemContainer
	com.vaadin.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1410)
	com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1364)
	com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

java.lang.UnsupportedOperationException: Use addNestedContainerProperty(String) to add container properties to a BeanItemContainer
	com.vaadin.data.util.AbstractBeanContainer.addContainerProperty(AbstractBeanContainer.java:798)
	com.vaadin.ui.AbstractSelect.addContainerProperty(AbstractSelect.java:806)
	com.vaadin.ui.Table.addContainerProperty(Table.java:4222)

I think adding a nested property does not make any sense here as the column should contain just some buttons which are not nested fields of the bean. And of course the following will not work:


((BeanItemContainer) table.getContainerDataSource()).addNestedContainerProperty("modify"); //noSuchMethod:... .areModify();

What’s wrong with the following code, and how can I add generated columns if I use beanitemcontainer?


Table table = new Table("mycaption");
BeanItemContainer<MyBean> container = new BeanItemContainer<MyBean>(MyBean.class);
table.setContainerDataSource(container);

table.addContainerProperty("modify", Button.class, null);
table.addGeneratedColumn("modify", new ColumnGenerator() {
	@Override
	public Component generateCell(final Table source, final Object itemId, final Object columnId) {
		HorizontalLayout hor = new HorizontalLayout();
		hor.addButton("Edit");
		hor.addButton("Delete");
		return hor;
	}
});

remove table.addContainerProperty("modify", Button.class, null);

you dont add the generated column to the container , you can however reference the generated column like a container property in some of the Table’s methods get/setColumnXxxxxx(propertyId,…) . A generatedColumn is a for generating custom display in a column, it does not (have to) reflect any property if the Item in the Container…