Selecting rows in generated columns

Hello, I’m starting with IT Mill and I’m trying to create a Table with data based on a set of POJOs. I’m using the BeanArrayContainer class from I modified it to handle visibility annotations in the BeanArrayContainer and not in my client code, but appart from this, it’s the same code. I got it working and now I need in my table some generated values. In fact only one field of the POJO will be shown and the rest will be generated from the POJO fields.

This is my code:

        userTable.addContainerProperty("visibleName", String.class, null, "Name", null, null);
        userTable.addGeneratedColumn("visibleName", new NameGenerator());

        userTable.addContainerProperty("age", String.class, null, "Age", null, null);
        userTable.addGeneratedColumn("age", new AgeGenerator());

        userTable.addContainerProperty("dob", String.class, null, "Date of Birth", null, null);
        userTable.addGeneratedColumn("dob", new DobGenerator());

        userTable.setContainerDataSource(new BeanArrayContainer(getTestUsers(), User.class));

        userTable.setVisibleColumns(new Object[]{"visibleName","dob","age","sex"});


The table is correctly generated but I can only select and reorder the column “sex” which is the one that is shown directly from the POJO. The other ones are generated and I cannot select rows clicking on them or reorder the table clicking on their headers.

You can not sort a generated column. The reason being that the values are generated on the fly - the next time they are generated, they could be different, so the sorting could be invalid. We could generate the values first, then sort, but then we’d have to generate all rows in order to know how to sort, so that’s not really feasible.

The selection problem is probably because the generated component ‘blocks’ the event in the browser - that is needed for some components (e.g Button), but not for others (e.g. Label). What components are you generating?

Best Regards,

I’m generating labels.

I’m generating labels.
[/quote]In that case you could probably just use plain Strings instead of the Label component, if you don’t need Label’s descriptions and icons.

String content allows click-through, so selecting rows will be easier.

But generateCell needs to return a component. How can I return a String?

Darn, I forgot about that. Then I got nothing, sorry. Anyone else have a solution?

It seems that the original post was a long time ago… Anyway, I’ve tried this exact same thing today - created a generated column and I’m returning a custom component.

This custom component which I call InfoCell descends directly from a VerticalLayout and inside it has a dozen labels , properly organized, just like I want.

Regarding the styles I had to create to change some of the labels unselected color and then again to inherit the selection style from upstream I had no problem, the problem is exactly the same as the OP.

I can select the row if I click on the very left of the cell, I’d say like a margin with 3px and the entire row is actually selected but if I click anywhere else in the cell, places where my child components are, no selection occurs.

The question remains, is there any solution so that these components could passthrough any click events or even ignore them?


this post
this example
for a solution. The solution has a minor flicker problem, see ticket

Now that’s fine. I’ve got in my head sort of similar solution.
But what if I want to work with muliselect.
I’m trying to figure out some nice&functional solution.

Well I’ve done this functional&ugly solution

public void layoutClick(LayoutClickEvent event) {
	Collection<PaymentFile> selected = (Collection<PaymentFile>) table.getValue();
	PaymentFile pf = (PaymentFile) itemId;
	if (selected.contains(pf)) {

		for (PaymentFile pfItem : (Collection<PaymentFile>) table.getItemIds()) {
			if (selected.contains(pfItem) && !pfItem.equals(itemId)) {;
	} else {;