title: Vaadin - passing data between views
body: <p>I'm very new in Vaadin and JavaEE at all and I have I think basic question, but will be glad for help.</p>
  
  <p>I have 3 classes in my Vaadin project, here they are:
  Main class, responding only for starting and creating navigator:</p>
  
  <pre><code>public class MyprojectUI extends UI {
  
  
      public Navigator navigator;
          public static final String SECOND_VIEW = "SecondView";
  
          @WebServlet(value = "/*", asyncSupported = true)
          @VaadinServletConfiguration(productionMode = false, ui = MyprojectUI.class)
          public static class Servlet extends VaadinServlet {
          }
  
          @Override
          protected void init(VaadinRequest request) {
              final VerticalLayout layout = new VerticalLayout();
              layout.setMargin(true);
              setContent(layout);
  
              ComponentContainerViewDisplay viewDisplay = new ComponentContainerViewDisplay(layout);
              navigator = new Navigator(UI.getCurrent(), viewDisplay);
              navigator.addView("", new FirstView());
              navigator.addView(SECOND_VIEW, new SecondView());
          }
  
      }
  </code></pre>
  
  <p>And two views class:</p>
  
  <pre><code>public class FirstView extends HorizontalLayout implements View {
  
      TextArea text = new TextArea();
      Button button = new Button("go");
  
      @Override
      public void enter(ViewChangeEvent event) {
          this.addComponent(text);
          this.addComponent(button);
          button.addClickListener(new ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                  getUI().getNavigator().navigateTo(MyprojectUI.SECOND_VIEW);
              }
          });
      }
  }
  </code></pre>
  
  <p>-</p>
  
  <pre><code>public class SecondView extends HorizontalLayout implements View {
  
      Label label = new Label("Passed text here");
  
      @Override
      public void enter(ViewChangeEvent event) {
          this.addComponent(label);
      }
  
  }
  </code></pre>
  
  <p>How can I pass a data from my TextArea to second view? I want set label text to text which was in TextArea when "go" button is clicked.</p>
  
  <p>Thanks for help.</p>