How to pass values from window back to a view

Hello,

I am new to Vaadin and I am having a couple of problems… What is the best way to pass values from a window back to a view? In my application I would like to get values from textfilds on an modal window and pass it back to a view, which has opened that window and fill textfields on that view.

Thank you for any help.

I’d say that the normal pattern to hande input done in a dialog window would be to have an “OK listener” or “save listener”, or in Java 8 just a Consumer of the edited data type.

public class MyDialog extends Window {
    @FunctionalInterface
    public interface SaveListener {
        public void save(SomeDataModel modifiedData);
    }

    public MyDialog(SaveListener save) {
       ...
    }
}
[/code]Then use it for example:[code]
SomeDataModel data;
...

MyDialog dlg = new MyDialog(data, (modifiedData) -> {
    data = modifiedData;
    Notification.show("Data changed");
});
UI.getCurrent().addWindow(dlg);

Hello Marko!

Thank you very much for your answer, it helped me solve the problem :).