gpt4 book ai didi

java - Vaadin 7 中的导航器

转载 作者:行者123 更新时间:2023-12-01 10:09:08 25 4
gpt4 key购买 nike

我使用导航器制作了一个 vaadin 7 导航应用程序,在其中我尝试从 UI 导航到 View ,但出现以下错误

java.lang.IllegalArgumentException: Trying to navigate to an unknown state '' and an error view provider not present error.

用户界面类:

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!!!");
}
}

找出我在这方面做错了什么,我将感激不已:)

最佳答案

正如异常(exception)所说,您没有与 '' 匹配的 View ;

你必须添加类似的内容;

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

或将 url 写为

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

关于java - Vaadin 7 中的导航器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36257641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com