O'Reilly logo

Vaadin 7 UI Design By Example Beginner's Guide by Alejandro Duarte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – preserving application state

Follow these steps to see how easy it is to preserve the state of UI components in Vaadin applications:

  1. Create a new Vaadin project. We are using keepstate as project name.
  2. Code your UI class:
    public class KeepstateUI extends UI {
    
      protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);
        TextField tf = new TextField(
            "Type, press ENTER, and refresh the browser");
        tf.setImmediate(true);
    
        tf.addValueChangeListener(new ValueChangeListener() {
          public void valueChange(ValueChangeEvent event) {
            Notification.show(
                "Value: " + event.getProperty().getValue());
          }
        });
    
        layout.addComponent(tf);
      }
    
    }
  3. Nothing new so far. Run the application, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required