Search code examples
javavaadin10

Why is my Vaadin 10 Component not displayed?


I am trying to display a Vaadin component, a grid with Vaadin 10 on my page.

It is there in the DOM but not visible on the Page.

My class is:

@Route("")
@Log
public class ProfileList extends VerticalLayout {     
    public ProfileList(PersonRepository repo) {
        Grid<Profile> grid = new Grid<>();
        grid.addColumn(Person::getName).setHeader("Name");         
        grid.setItems(profilerepo.findAll());
        add(grid);    
    }   
}

Solution

  • The problem is, that the VerticalLayout is not increasing its size to fit the grid.

    Because the grid is below the visible area of the VerticalLayout, it is hidden.

    A simple fix would be to use:

    setSizeFull();
    

    Which tells the VerticalLayout to span the page.