I'm very new in Vaadin and JavaEE at all and I have I think basic question, but will be glad for help.
I have 3 classes in my Vaadin project, here they are: Main class, responding only for starting and creating navigator:
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());
}
}
And two views class:
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);
}
});
}
}
-
public class SecondView extends HorizontalLayout implements View {
Label label = new Label("Passed text here");
@Override
public void enter(ViewChangeEvent event) {
this.addComponent(label);
}
}
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.
Thanks for help.
SecondView secondView = new SecondView();
navigator.addView(SECOND_VIEW, secondView );
Presenter presenter = new Presenter(firstView, secondView);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With