alejandro-du / crudui

Automatically generate CRUD-like Vaadin views for any Java Bean
https://vaadin.com/directory#!addon/crud-ui-add-on
Apache License 2.0
86 stars 54 forks source link

2.1.0 not showing content in grid #13

Closed jonmartinsolaas closed 7 years ago

jonmartinsolaas commented 7 years ago

I have a spring-boot program (version 1.5.2) and have added an UI

` package com.example;

import com.vaadin.server.VaadinRequest; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringUI; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.UI; import org.vaadin.crudui.crud.impl.GridBasedCrudComponent;

import java.util.Arrays; import java.util.List;

@SpringComponent @SpringUI(path = "/demo") public class MyUI extends UI {

HorizontalLayout layout = new HorizontalLayout();
GridBasedCrudComponent<UserBean> crud = new GridBasedCrudComponent<>(UserBean.class);

@Override
protected void init(VaadinRequest request) {
    crud.setFindAllOperation(() -> UserBean.getSome());
    layout.addComponent(crud);
    setContent(layout);

}

public static class UserBean {
    private String givenName;
    private String surName;

    public UserBean(String givenName, String surName) {
        this.givenName = givenName;
        this.surName = surName;
    }

    public static List<UserBean> getSome() {
        return Arrays.asList(
                new UserBean("Tom","Hansen")
                , new UserBean("Odd", "Jensen")
        );
    }

    public String getGivenName() {
        return givenName;
    }

    public void setGivenName(String givenName) {
        this.givenName = givenName;
    }

    public String getSurName() {
        return surName;
    }

    public void setSurName(String surName) {
        this.surName = surName;
    }
}

} `

I think this is as minimalistic as can be. Values are not shown in the grid, though. On reload the notification shows that two rows are found. But the grid is just blank. Is this due to 2.1.0 not being released yet?

grid.setItems(items); in GridBasedCrudComponent do happen in the debugger, and items is of size 2 as expected, so it's a bit weird.

jonmartinsolaas commented 7 years ago

Had to use addColumn to show data:

((Grid<UserBean>)crud.getGrid()).addColumn(UserBean::getSurName); ((Grid<UserBean>)crud.getGrid()).addColumn(UserBean::getGivenName);