Table rendering rows and columns but they are empty

Hello,

I’ve created an application that loads some data from the database. As the table I want to display is not only a simple display of one entity (or entity with some related entities), I created my own container and am constructing it with my own logic.

However, when I attach this container to a Table, table rows and columns get rendered, also a footer gets rendered (shows correct values from the container so that means the data is there), but the cells in the table are totally empty.

I am attaching a screenshot.

Here is a sample of relevant code:

DochadzkaContainer.java

@Repository
@Scope(value = BeanDefinition.SCOPE_PROTOTYPE)
public class DochadzkaContainer extends IndexedContainer {

    public static final String HEADER_ID = "id";
    public static final String HEADER_TERMIN = "Termín";    
    public static final String HEADER_PRITOMNY = "Prítomný";
    public static final String HEADER_CAS_PRICHODU = "Čas príchodu";
    public static final String HEADER_CAS_ZAPISU = "Čas zápisu";
    public static final String HEADER_ZAPISAL = "Zapísal";
    
    @Autowired
    private InstanciaOknaRepository instanciaOknaRepository;
    
    private int celkomOkien = 0, pritomnychOkien = 0;
    
    public DochadzkaContainer() {        
        addContainerProperty(HEADER_ID, Long.class, null);
        addContainerProperty(HEADER_TERMIN, String.class, null);
        addContainerProperty(HEADER_PRITOMNY, Boolean.class, null);
        addContainerProperty(HEADER_CAS_PRICHODU, String.class, null);
        addContainerProperty(HEADER_CAS_ZAPISU, String.class, null);
        addContainerProperty(HEADER_ZAPISAL, String.class, null);        
    }
    
    public void load(PredmetInstancia predmetInstancia, Osoba osoba) {        
        removeAllItems();
        List<InstanciaOkna> data = instanciaOknaRepository.findByOsobaPreTabulkuDochadzky(osoba, predmetInstancia);        
        celkomOkien = data.size();
        pritomnychOkien = 0;
        DateFormat format = new SimpleDateFormat("d.M.yyyy H:m");
        DateFormat formatSoSekundami = new SimpleDateFormat("d.M.yyyy H:mm:ss");        
        for (InstanciaOkna instanciaOkna: data) {            
            boolean pritomny = !instanciaOkna.getZaznamy().isEmpty();
            if (pritomny)
                pritomnychOkien++;
            Zaznam zaznam = instanciaOkna.getZaznamy().isEmpty() ? null : instanciaOkna.getZaznamy().get(0);
            String casPrichodu = (zaznam == null) ? null : formatSoSekundami.format(zaznam.getCasPrichodu());
            String casZaznamu = (zaznam == null) ? null : formatSoSekundami.format(zaznam.getCasZaznamu());
            String zapisal = (zaznam == null) ? null : zaznam.getZaznamenalOsoba().getPlneMeno();
            Object[] item = new Object[]
 {instanciaOkna.getId(), format.format(instanciaOkna.getDatumcasOd()), pritomny, casPrichodu, casZaznamu, zapisal};
            addItem(item);            
        }
    }
    
    public int getCelkomOkien() {
        return celkomOkien;
    }
    
    public int getPritomnychOkien() {
        return pritomnychOkien;
    }
    

}

Presenter:

...
...
private void nacitajTabulkuPreZvolenyPredmet() {
        ComboBox predmetyComboBox = view.getPredmetSelectorComboBox();
        if (predmetyComboBox.getValue() == null)
            return;
        PredmetInstancia instancia = (PredmetInstancia) predmetyComboBox.getValue();
        dochadzkaContainer.load(instancia, loggedUser.getOsoba());
        view.naplnTabulku(dochadzkaContainer);        
    }
...
...

PrezeranieDochadzkyView.java:

public class PrezeranieDochadzkyView extends MainView implements Serializable, ColumnGenerator {
    private static final Logger logger = LoggerFactory.getLogger(PrezeranieDochadzkyView.class);

    private HorizontalLayout predmetPickerLayout = new HorizontalLayout();
    private ComboBox predmetSelectorComboBox = new ComboBox();
    private Table dochadzkaTable = new Table();

    public PrezeranieDochadzkyView() {
        Label predmetLabel = new Label("Predmet:");
        predmetLabel.setSizeUndefined();
        predmetSelectorComboBox.setWidth(400, Unit.PIXELS);
        predmetSelectorComboBox.setNullSelectionAllowed(false);
        predmetSelectorComboBox.setTextInputAllowed(false);
        predmetSelectorComboBox.setImmediate(true);

        predmetPickerLayout.addComponent(predmetLabel);
        predmetPickerLayout.addComponent(predmetSelectorComboBox);
        predmetPickerLayout.setWidth(100, Unit.PERCENTAGE);
        predmetPickerLayout.setExpandRatio(predmetSelectorComboBox, 1.0f);
        addComponent(predmetPickerLayout);

        addComponent(dochadzkaTable);
        setExpandRatio(dochadzkaTable, 1.0f);
        dochadzkaTable.setSizeFull();

        vyrobStlpceTabulky();
    }

    @Override
    public void enter(ViewChangeEvent event) {

    }

    @Override
    public Object generateCell(Table source, Object itemId, Object columnId) {
        Item item = source.getItem(itemId);
        Property<Boolean> property = source.getContainerDataSource().getContainerProperty(itemId, DochadzkaContainer.HEADER_PRITOMNY);
        CheckBox checkBox = new CheckBox();
        checkBox.setValue(property.getValue());
        checkBox.setReadOnly(true);
        return checkBox;
    }

    public ComboBox getPredmetSelectorComboBox() {
        return predmetSelectorComboBox;
    }

    // stlpce: Termin, Pritomny, cas prichodu, cas zapisu, zapisal
    public void naplnTabulku(DochadzkaContainer dataSource) {
        dochadzkaTable.setContainerDataSource(dataSource);
        dochadzkaTable.setColumnFooter(DochadzkaContainer.HEADER_PRITOMNY,
                String.format("Celkovo prítomný: %d z %d", dataSource.getPritomnychOkien(), dataSource.getCelkomOkien()));
        dochadzkaTable.setVisibleColumns(DochadzkaContainer.HEADER_TERMIN, DochadzkaContainer.HEADER_PRITOMNY,
                DochadzkaContainer.HEADER_CAS_PRICHODU, DochadzkaContainer.HEADER_CAS_ZAPISU, DochadzkaContainer.HEADER_ZAPISAL);
    }

    private void vyrobStlpceTabulky() {
//        dochadzkaTable.addGeneratedColumn(DochadzkaContainer.HEADER_PRITOMNY, this);
        dochadzkaTable.setFooterVisible(true);
    }

}

13376.png