导航员在Vaadin 7

时间:2016-03-28 07:08:03

标签: java vaadin7

我使用导航器创建了一个vaadin 7导航应用程序,其中我尝试从UI导航到View,但收到以下错误

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 个答案:

答案 0 :(得分:1)

如异常所述,您没有与'';

匹配的视图

您必须添加类似的内容

navigator.addView("", Welcome.class);

或将网址写为

http://localhost:8080/context_root/#!abc