Why does a Viewer not update after Editor edits a Property?

Following the examples in the Book of Vaadin
page on Properties
, I created on ObjectProperty, with both a Viewer and Editor of that property in a Window.

The page says the Viewer should update automatically when the Editor edits.

But not so in my attempt.

When the user edits the Property using the Editor, the Viewer does not get updated on screen automatically. If some other redraw occurs, such as a Button causing some other Label to get a new value, then the Viewer re-displays properly.

==> Why does the Viewer (Label) not get updated when the Editor (TextField) edits?

I tried setting the window’s Immediate mode to True. Did not help.
I tried setting the TextField’s WriteThrough to True. Did not help. (Already the default)

I wrote a simple example, complete in a single class.

Here’s the core part, creating the Property, Viewer, and Editor.

        String initTime = new java.util.Date().toString(); // Get the current datetime.
        prop = new ObjectProperty( initTime, String.class ); // Our data model. Initialize with current datetime.

        // Create a Label to view our Property.
        viewer = new Label(); // Component that implements com.vaadin.data Property.Viewer
        viewer.setCaption( "Current value of prop:" );
        viewer.setPropertyDataSource( prop ); // Bind it to the data
        mainWindow.addComponent( viewer );

        // Create a TextField to edit our Property.
        editor = new TextField( "this string should NOT appear on screen" ); // Component that implements com.vaadin.data Property.Editor
        editor.setCaption( "Set my property:" );
        editor.setPropertyDataSource( prop ); // Bind the Property to the Editor.
        //editor.setWriteThrough( true ); // True is the default.
        mainWindow.addComponent( editor );

And here’s the entire class, to replace the contents of the class created by the Vaadin Eclipse plugin’s New Vaadin Project:

package com.example.propertyexperiment;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import com.vaadin.Application;
import com.vaadin.data.Property;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.ui.*;

public class PropertyexperimentApplication extends Application implements Button.ClickListener {
    Property prop = null;
    Label viewer = null;
    TextField editor = null;
    
    Button nowButton = null;
    Label nowLabel = null;

    @Override
    public void init() {
        Window mainWindow = new Window( "Propertyexperiment Application" );
        Label label = new Label( "Hello Bonjour Vaadin user" );
        mainWindow.addComponent( label );
        
        //mainWindow.setImmediate( true ); // Does not help make the Viewer update after Editor edits.

        String initTime = new java.util.Date().toString(); // Get the current datetime.
        prop = new ObjectProperty( initTime, String.class ); // Our data model. Initialize with current datetime.

        // Create a Label to view our Property.
        viewer = new Label(); // Component that implements com.vaadin.data Property.Viewer
        viewer.setCaption( "Current value of prop:" );
        viewer.setPropertyDataSource( prop ); // Bind it to the data
        mainWindow.addComponent( viewer );

        // Create a TextField to edit our Property.
        editor = new TextField( "this string should NOT appear on screen" ); // Component that implements com.vaadin.data Property.Editor
        editor.setCaption( "Set my property:" );
        editor.setPropertyDataSource( prop ); // Bind the Property to the Editor.
        //editor.setWriteThrough( true ); // True is the default.
        mainWindow.addComponent( editor );
        
        TextField ignoreTextField = new TextField("whatever");
        ignoreTextField.setCaption( "Ignore this field - here to accept focus:" );
        mainWindow.addComponent( ignoreTextField );
        
        nowLabel = new Label("the now label");
        nowButton = new Button("Now:");
        nowButton.addListener( this );
        mainWindow.addComponent( nowButton );
        mainWindow.addComponent( nowLabel );

        setMainWindow( mainWindow );
    }
    
    public void buttonClick(Button.ClickEvent event) {
        String newValue = new java.util.Date().toString();
        nowLabel.setValue( newValue );
    }

}