mari mari - 1 month ago 23
Java Question

How can l set the values of a column in vaadin table to link or button?

I need to convert values in column "anzahl" to links or buttons, and l am struggling with the structure of vaadin table. I am getting database values from mysql table name "SYSTEM" (within entity class System).

This is my table properties which l have defined:

private void initSystemTable() {
JPAContainer<System> systems = new SystemServiceDB().getAllSystems();
table_system.setVisibleColumns(new Object[] { "softwarebezeichung", "version", "anzahl", "lizenzen" });
table_system.setColumnHeader("softwarebezeichung", "Softwarebezeichung");
table_system.setColumnHeader("version", "Version");
table_system.setColumnHeader("anzahl", "Anzahl");
table_system.setColumnHeader("lizenzen", "Vorhandene lizenzen");

and class SystemServiceDB:

public class SystemServiceDB implements SystemService{

public JPAContainer<System> getAllSystems()
JPAContainer<System> systems = JPAContainerFactory.make(System.class, "help-pu");

return systems;

This is my output table:

enter image description here

I can't use
to set the column as l load these values from mysql, I can't find the way to solve this problem. I will appreciate if anyone can help me to solve this.

table_system.addContainerProperty("anzahl", Link.class, null);
table_system.addContainerProperty("anzahl", Button.class, null);


Use generated columns.

This is an example of a generated column with a button:

table.addGeneratedColumn("generated", new ColumnGenerator() {

        public Component generateCell(Table source,
                    final Object itemId, Object columnId) {
            Button button = new Button("caption");
            //Listener for the button
            button.addClickListener(Event -> {
                //Your code
            return button;