Hi there,
I just started Vaadin and so far so good - it really looks promising, however I really struggle with the Navigator. I tried so many things I found on the internet, but none seems to work. I would appreciate it, if you guys can tell me, what I am doing wrong. Here is my source code
@Theme("mytheme")
@Widgetset("de.javahouse.jobwiz.MyAppWidgetset")
public class BasicInformation extends UI {
public static final String VIEW_NAME_BASIC = "basic_view";
public static final String VIEW_NAME_ADV = "advanced_view";
private Navigator nav;
private static final long serialVersionUID = 2548993131483469880L;
@Override
protected void init(VaadinRequest vaadinRequest) {
HorizontalLayout layout = generateContent();
nav = new Navigator(this,this);
nav.addView(VIEW_NAME_ADV, new AdditionalInformation());
//this doesnt work either
//nav.addView(VIEW_NAME_BASIC, (Class<? extends View>) BasicInformation.class);
setContent(layout);
}
private HorizontalLayout generateContent(){
HorizontalLayout layout = new HorizontalLayout();
FormLayout form = new FormLayout();
OptionGroup single = new OptionGroup("Gender");
single.addItems("Male", "Female");
form.addComponent(single);
TextField tfFirstname = new TextField("First Name");
tfFirstname.setRequired(true);
form.addComponent(tfFirstname);
TextField tfFamilyName = new TextField("Family Name");
tfFamilyName.setRequired(true);
form.addComponent(tfFamilyName);
TextField tfEmail = new TextField("E-mail");
tfEmail.setRequired(true);
form.addComponent(tfEmail);
Button btSave = new Button("Save and Proceed");
btSave.addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
nav.navigateTo(VIEW_NAME_ADV);
}
});
form.addComponent(btSave);
layout.addComponent(form);
return layout;
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = BasicInformation.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
}
}
public class AdditionalInformation extends VerticalLayout implements View {
private static final long serialVersionUID = 1578488973205488083L;
public AdditionalInformation(){
Label lbl = new Label("Whatever");
addComponent(lbl);
}
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
// TODO Auto-generated method stub
}
}