我使用navigator创建了一个vaadin7导航应用程序,在该应用程序中,我试图从ui导航到视图,但出现以下错误
java.lang.IllegalArgumentException: Trying to navigate to an unknown state '' and an error view provider not present error.
ui类:
public class NavigationUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = NavigationUI.class)
public static class Servlet extends VaadinServlet {
}
final private String navigatorView = "NEXT";
private Navigator navigator = null;
@Override
protected void init(VaadinRequest request) {
HorizontalLayout hori = new HorizontalLayout();
final VerticalLayout layout = new VerticalLayout();
hori.setMargin(true);
layout.setMargin(true);
setContent(hori);
hori.addComponent(layout);
Panel pnl = new Panel();
hori.addComponent(pnl);
navigator = new Navigator(this,pnl);
navigator.addView("abc", Welcome.class);
Button button = new Button("Click Me");
layout.addComponent(button);
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
navigator.navigateTo("abc");
}
});
}
}
视图类:
public class Welcome extends VerticalLayout implements View {
public Welcome() {
// TODO Auto-generated constructor stub
VerticalLayout layout = new VerticalLayout();
Button back = new Button("Go Back");
layout.addComponent(back);
addComponent(layout);
}
@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub
Notification.show("Welcome Here!!!");
}
}
找出我在这方面做错了什么,我会很感激:)
1条答案
按热度按时间cotxawn71#
如异常所述,您没有与“”匹配的视图;
你必须加上这样的东西;
或将url写入