Vaadin 8 - ButtonRenderer getItem() in Grid Issue

Hello!

I want to have a button that returns the selected element set up as such:

Grid<CustOrderItem> gridMain = new Grid<>();
gridMain.setItems(objectTypeList);
gridMain.addColumn(orderItem -> orderItem.getRequestId(), new ButtonRenderer(clickEvent -> {
            System.out.println("ELEMENT "+((ObjectType) clickEvent.getItem()));          
        })).setCaption("Whatever")

This works like a charm until you start to have elements in the objectTypeList that have duplicate values. In that case it will return the last element with the duplicate values.

Anyone else experiencing this issue?

Thanks!!!

Did you try implementing hashCode in your class?

-Olli

Hi Olli,

I did, but I did it on the field that has duplicates!

Thanks Olli! Helpful as always