Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
SqlContainer and addGeneratedColumn
Hi,
I am using SqlContainer and TableQuery to retrieve data from an existing database table and show the data in a Table by setting the table's datasource to the SqlContainer. Everything works fine and the data is shown as expected.
Table t = new Table();
TableQuery q = new TableQuery("MyTable",
MyApplication.getInstance().getDatabaseManager().getConnectionPool(),
MyApplication.getInstance().getDatabaseManager().getSQLGenerator());
SQLContainer container = new SQLContainer(q);
t.setContainerDataSource(container);
Now I have some boolean columns in my database and I want to show them as icons. I tried to use a ColumnGenerator for the boolean column and returning a Label field, where I set the icon. But the icon is not shown. It still shows only the content (value) of the column: true / false
Removing the setValue() on the new label field, results that nothing is shown in the table.
private void addColumnGenerator()
{
addGeneratedColumn("theBooleanColumn", new ColumnGenerator()
{
public Object generateCell(Table source, Object itemId, Object columnId)
{
System.out.println("itemId: " + itemId + ", columnId: " + columnId);
if (getItem(itemId).getItemProperty("theBooleanColumn").getValue() != null)
{
Label l = new Label();
l.setIcon(new ThemeResource("icons/32/ok_32.png"));
l.setValue(getItem(itemId).getItemProperty("theBooleanColumn").getValue());
return l;
}
return null;
}
});
}
How can I do this?
I also tried to use addContainerProperty() on the boolean column, but this results in a OperationNotSupportedException.
container.addContainerProperty("theBooleanColumn", Resource.class, null);
Any hints welcome ;-)
You should use an Embedded instead of a Label inside your generateCell method. That's the way I present icons to the user.
Thanks for the hint to use Embedded - now it looks like expected :-)