Null Item properties when using Table.ColumnGenerator


In my application I have a view that displays a List of object represented by different UI Components depending on the underlying object type.

I have built this by using a Table with a datasource set to a Container based on IndexedContainer - what I actually do in my container is to store a BeanItem indexed against the underlying beans id property.

The problem I am getting is as discussed in
this ticket
, the table is asked to generate the Component before the properties have been set on the Item in the container.

class MyTable extends Table	{

	/**	The 'View' column will contain a Component (composite) depending on 
		the underlying data type.
	private void addViewColumn()	{
		void addGeneratedColumn("view", new ColumnGenerator()	{
			public Component generateCell(Table source, Object itemId,
					Object columnId)
				Item item = getContainerDataSource().getItem(itemId);
				final Object bean = item.getItemProperty(MyIDBeanContainer.PROP_BEAN).getValue();

				return CustomComponentFactory.getInstance().getView(bean);
		setColumnExpandRatio("view", 1f);

Unfortunately I don’t think the suggested work around is quite right for my situation because my container receives updates from my Business tier, these updates add/remove/update items in the DataSource which I obviously want to reflect is the already existing, and attached Table.

I see there being a few option but I would like input/suggestion on where I am going wrong, or how I should proceed.

  1. Improved container.

In my container I want to store the underlying Bean against an ID of my choosing - the beans own id property to facilitate interaction with by Business services and database. e.g container.addItem(bean.getID()).

Unfortunately I cannot add the Item properties at the same time as creating the new Item, this could pre-prepare the Item Before adding it to the Container, and thus before the Table is requested to build the Component.

e.g. My container internally uses BeanItem to work out the properties based on the bean type I want to container to represent.
BeanItem my_bean_item = new BeanItem(new myBean());
container.addItem(bean.getID(), my_bean);

or even.

container.add(my_bean_item); where the container knows which bean property to use as the ID.

Perhaps this is already possible and I just do not know that part of the API yet? I have started to attempt to develop this functionality, but I think I would have to build from a very basic base class rather than be able to extend something like IndexedContainer .

  1. Another possibility is not to use Table as my Component container (I do not require Table features such as select, sorting etc.), instead use another UI Component - which would be appropriate? This would able to add/remove an appropriate Component following some event trigger from its data source - if this is possible what Components/Datasources exist to support this?

  2. A final possibility is that there is an method or even handler on the table that I could call or activate that would cause the Table to redraw, I imagine performance would not be as efficient but may be a quick fix for my use case.

Any advice, suggestions or recommendations would be gratefully received.