Grid editor does not show errors when buffered

I am trying to use the grid with inline editing and I would like for errors to be displayed when they occur. I am seeing that if the editor mode is buffered the error message are not shown, but the editor is unbuffered they do show. Is there a way to get the errors to show in buffered mode or is this a defect? I am using Vaadin 8.1.6.

Here is an example using a popup window in my app to demo the problem.

public class ValidateBean {
    private String value = "Some Value";
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}

...

Button button = new Button("Binding Test");

// open a window with buffered and unbuffered grid
button.addClickListener(event -> {
    VerticalLayout l = new VerticalLayout();
    l.addComponents(createGrid(true), new Label("spacer"), createGrid(false), new Label("spacer"));

    Window w = new Window("Grid Binding Test");
    w.setWidth("800px");
    w.setHeight("600px");
    w.center();
    w.setContent(l);
    UI.getCurrent().addWindow(w);
});

private Grid<ValidateBean> createGrid(boolean buffered) {
    Grid<ValidateBean> g = new Grid<ValidateBean>();
    List<ValidateBean> list = new ArrayList<>();
    list.add(new ValidateBean());
    g.setItems(list);
    g.setHeightByRows(1);

    Editor<ValidateBean> editor = g.getEditor();
    editor.setEnabled(true);

    Binder<ValidateBean> binder = editor.getBinder();

    TextField field = new TextField();

    Binder.Binding<ValidateBean, String> binding = binder.withValidator(x -> {
            return !x.getValue().contains("error");
        }, "Error found in text")
        .bind(field, ValidateBean::getValue, ValidateBean::setValue);

    editor.setBuffered(buffered);
    Grid.Column c = g.addColumn(ValidateBean::getValue);
    c.setCaption("Value (" + (buffered ? "Buffered)" : "Unbuffered)"));
    c.setEditorBinding(binding);

    return g;
}

When I run this and add “error” into the editor, in buffered mode the error is not displayed, but in unbuffered mode the error is displayed. When I save in buffered mode if there is an error the value reverts to its previous value (with no indication of any error), otherwise the save works as expected. I have attached a screen shot showing the output of this test.

39422.png

Yes, I can see that the behavior is not according to Editing Items Inside Grid in
Grid documentation
and https://vaadin.com/docs/v8/framework/components/components-grid.html which indicates that you are likely to have found a bug.

I’ve seen some issue reporting regarding Editor when Grid is in TabSheet https://github.com/vaadin/framework/issues/10146 , have you checked if Window has something to do about this?

I made the example above to demo the problem, but I see the same behavior in a regular view in the main UI in the grids I create. I tweaked my application to include the example grids in the example above as well. If I set the grid editor to NOT buffered I can see the errors being reported, if I set the editor to buffered I don’t.

In many cases we use JSR-303 annotation based validation and I am not sure if this is working in either case (buffered or unbuffered), but the first issue I see revolves around buffering when I tried to break the problem down into a simple validation example. I am working on transitioning some infrastructure we created around tables and inline editing and trying to adapt it to use grids instead.