Skip to content

Vaadin 8 Grid does not properly updates contents after editing when equals and hashCode are overriden #8476

@SomeoneToIgnore

Description

@SomeoneToIgnore

Vaadin 8 version: 8.0-SNAPSHOT

Steps to reproduce:

  • create Grid, map it to some pojo with equals and hasCode overriden
  • add column mapped to pojo's field and allow editing the column
  • add items to Grid.
  • open the UI, edit the column value, click save

Expected behavior:
Table view is updated to new value right after the editing
Actual behavior:
Table view is not updated unless table is refreshed (sorting is changed or anything else is done)

If no equals and hasCode is present, everything works as expected.

Example:

@SpringUI
@Theme("valo")
public class SampleVaadinJavaUi extends UI {

    @Override
    protected void init(VaadinRequest request) {
        Grid<Data> table = new Grid<>();
        table.addColumn(Data::getText).setCaption("text").setEditorComponent(new TextField(), Data::setText);
        table.getEditor().setEnabled(true);
        table.setItems(new Data("zzzzzz"));
        setContent(table);
    }

    private static class Data {
        private String text;

        private Data(String text) {
            this.text = text;
        }

        private String getText() {
            return text;
        }

        private void setText(String text) {
            this.text = text;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) { return true; }
            if (o == null || getClass() != o.getClass()) { return false; }
            Data data = (Data) o;
            return Objects.equals(text, data.text);
        }

        @Override
        public int hashCode() {
            return Objects.hash(text);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions