Hi everybody,
I want to use the Addon ComponentRenderer: https://vaadin.com/directory#!addon/componentrenderer
It renders standard components in a Grid, so you can build a cell with a text and a picture in one Gridcell for example.
But all my tries are not working. I just get an empty Grid as result.
I am thankful for any help or advice. Thanks!
package view;
import java.util.ArrayList;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Component;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import controller.TippappManager;
import entities.*;
import model.UserDaten;
import de.datenhahn.vaadin.componentrenderer.grid.ComponentGenerator;
import de.datenhahn.vaadin.componentrenderer.grid.ComponentGridDecorator;
public class ClassicGrid extends VerticalLayout {
public ClassicGrid (TippappManager manager, UserDaten userDaten) {
setSizeFull();
setMargin(true);
setSpacing(true);
Grid grid = new Grid();
grid.setContainerDataSource(new BeanItemContainer<Spiel>(Spiel.class));
ComponentGridDecorator<Spiel> componentGridDecorator = new ComponentGridDecorator<>(grid, Spiel.class);
int turnierID = userDaten.getUserTippgruppeByID(manager.getCurrentTippgruppe()).getTurnierId();
ArrayList<Spiel> offeneSpiele = userDaten.getSpiele().get(turnierID);
componentGridDecorator.addAll(offeneSpiele);
grid.setSizeFull();
grid.setEditorEnabled(true);
grid.setEditorBuffered(false);
ComponentGenerator<Spiel> generatorIcon = new ComponentGenerator<Spiel>() {
@Override
public Component getComponent(Spiel bean) {
return new Label(FontAwesome.HOURGLASS_2.getHtml(), ContentMode.HTML);
}
};
ComponentGenerator<Spiel> generatorText = new ComponentGenerator<Spiel>() {
@Override
public Component getComponent(Spiel bean) {
return new Label(FontAwesome.HOURGLASS_2.getHtml(), ContentMode.HTML);
}
};
componentGridDecorator.addComponentColumn("icon", generatorIcon);
componentGridDecorator.addComponentColumn("text", generatorText);
// always display the details column
grid.setFrozenColumnCount(1);
grid.setColumns( "icon", "text");
addComponent(grid);
// setExpandRatio(grid, 1.0f);
}
}