Creating grid returns error pagesize 0 error message

I am getting an error using a grid in my ShowPersonsView. When the constructor goes to instantiate the view the grid constructor throws an exception:

The pageSize should be greater than zero. Was 0

The source code looks something like this:

Grid grid = new Grid<>(Person.Class);
grid.setItems(service.findAll());
add(grid);

Why is it doing that?

the code snippet looks ok. I assume your real code looks different

The code snippet is exactly what I have in the code right now.

I think it is defaulting to the wrong constructor.

public Grid(int pageSize)

versus

public Grid(Class<T> beanType, autoCreateColumns)

No

There is also a constructor other wise you would get a compilation error

When I step into the code and manually set the page size to 1 it all works.

Go to https://start.vaadin.com and create a master-detail view. then compare this code with yours

Ahhh… yes I’ve use this tool to generate a project, but I am not sure how to add a Grid to it.

Here is a good video where a Grid is used:
https://www.youtube.com/watch?v=3WqwKLz43JM

I think Simon knows what a Grid is used for :wink: the problem comes from the fact that he doesn’t know how you managed to get to this state. It’s technically impossible with a class reference as constructor parameter to get the grid to have a page size of zero looking at the code, so there must be something wrong in your code

Well I think this has to do with him using a Maven project versus me using a Gradle project.

Also, when I Git clone his project I am getting some Node.js NPM errors. Hmm…