Grid only recognizes it's last 5 rows

Hello everyone.

I’m working on a Vaadin app (with Vaadin 7.10), and I have faced a serious problem.
I writing a view with a VerticalSplitPanel and a Grid. The grid gets its elements from a BeanItemContainer, and when you select one of these elements, it’s info is shown in the superior part of the split panel. I have already done this a couple of times without problem.

Now, when I populate the grid with more than 5 elements, only the last 5 elements (ie: those who are at the bottom of the grid) are properly recognized by the grid. If you select one of the “last-5” everything is OK, and info is shown. If you select any other, the grid says that you have selected a null row, even if it is shown.

But this is not the weirdest thing. If I click any of the headers of the grid, to sort it, suddenly, everything works fine and nice.

Here is the relevant code:

BeanItemContainer container;
private void generateGrid() {

    Grid grid = new Grid();
    container = new BeanItemContainer<>(A.class);
    GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(container);

    generateColumns(gpc);

    grid.setSizeFull();
    grid.setContainerDataSource(gpc);

    grid.setColumns("name", "opc");
    grid.getColumn("opc")
        .setRenderer(new ComponentRenderer());

    listado.addSelectionListener(ev -> {
        Object itemId = listado.getSelectedRow();
        if(itemId != null)
            //Do something
        else
            //Do something else
    });

}

private void generateColumns(GeneratedPropertyContainer gpc) {
    gpc.addGeneratedProperty("opc", new PropertyValueGenerator<HorizontalLayout>() {

            @Override
            public HorizontalLayout getValue(Item item, Object itemId, Object propertyId) {
                HorizontalLayout hl = new HorizontalLayout();
                
                Button bEdit = new Button("edit");
                bEdit.addClickListener(ev -> {
                  //do something
                });
                
                hl.addComponent(bEdit);
                return hl;
            }

            @Override
            public Class<HorizontalLayout> getType() {
                return HorizontalLayout.class;
            }
        });
}

private void loadContent() {
    container.removeAllItems();

    //Load them from a DB
}

I have tracked the error and I have the suspect that RPC calls twice to get grid’s rows, but it only calls for the last 5 the second time.
Any help?

My wild guess is that you are using
ComponentRenderer
add-on? Sounds like a problem to be
reported there
. Your code works just fine without it.
Please do let me know if you managed to reproduce the issue in the Grid without add-ons?


A^2