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