瓦丁导航器 NPE



我无法让Vaadin Navigator开始工作。 出于某种原因,我总是得到一个 NPE。 也许你们可以帮助我。 我不得不提一下,我刚刚从Vaadin开始。

所以这是代码

@Theme("mytheme")
@Widgetset("de.javahouse.jobwiz.MyAppWidgetset") 
public class BasicInformation extends UI {
public static final String VIEW_NAME_BASIC = "basic";
public static final String VIEW_NAME_ADV = "advanced";
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());

这也不能正常工作nav.addView(VIEW_NAME_BASIC, (Class) 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
}

}

这是我收到的错误消息。 我不知道我做错了什么。 感觉就像我检查了所有在线教程并完全像它们一样复制了它。

顺便说一句:我正在使用码头来运行网站(仅用于测试)

javax.servlet.ServletException: com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: Trying to navigate to an unknown state '' and an error view provider not present
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:366)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1667)
    at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:172)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:497)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: Trying to navigate to an unknown state '' and an error view provider not present
    at com.vaadin.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1464)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1421)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
    ... 24 more
Caused by: java.lang.IllegalArgumentException: Trying to navigate to an unknown state '' and an error view provider not present
    at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:575)
    at com.vaadin.ui.UI.doInit(UI.java:687)
    at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:214)
    at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
    ... 25 more

提前非常感谢

Vaadin 论坛中有一个关于这个问题的帖子

我遇到了这个问题,解决方法是模拟一个空的引用视图。在您的情况下,我命令您设置

public static final String VIEW_NAME_ADV = ""; // force to empty string

否则,相同的 VAADIN 线程指示修复错误视图实例可以修复

this.navigator.setErrorView(myView);

相关内容

  • 没有找到相关文章