Help on frequent Out of sync

Hello,

I am new to Vaadin framework.
I have created a very simple Vaadin application which displays a notification message whenever a button is clicked.


public class VaadintestApplication extends Application {
	@Override
	public void init() {
		Window mainWindow = new Window("Vaadintest Application");		
		setMainWindow(mainWindow);

		Label label = new Label("Name");
		mainWindow.addComponent(label);

		final TextField nameTxtField = new TextField();
		mainWindow.addComponent(nameTxtField);
		
		getMainWindow().addComponent(new Button("Notify", new Button.ClickListener() {
			
			private static final long serialVersionUID = 1L;

			@Override
			public void buttonClick(ClickEvent event) {
				getMainWindow().showNotification("Notified " + nameTxtField);
			}
		}));
		
	}	

}

If I access the application using a single browser window, everything works perfectly fine.
I get “Out of sync” error when I follow following steps:
1) Open a browser window and access the application → the application gets loaded
2) Open another browser window and access the application → the application gets loaded
3) Now go to the “first” browser window and click on “Notify” button it displays “Out of sync” error message.

I have not performed any action but I get this error message.

What can be the reason for this message? Is this how all Vaadin applications work?

Thanks

Hi,

Override getWindow() in your application, something like

    @Override
    public Window getWindow(String name) {
        Window w = super.getWindow(name);
        if (w == null) {
                w = new MyFooBarWindow(); // it's best to have separate classes for your windows
                w.setName(name);
                addWindow(w);
        }
        return w;
    }

Book of Vaadin also contains more on the subject, as do numerous forum posts.

Best Regards,
Marc

Thanks Marc
It works fine.
It also explains why application cannot retain its state in the new browser window.

Thanks