0

当我关注这个 vaadin 时:https ://vaadin.com/book/-/page/advanced.urifu.html关于如何正确使用的教程UriFragmentUtility,我最终创建了对象,并在尝试将此组件添加到我的主窗口,它会失败,但出现以下异常:

SEVERE: Servlet.service() for servlet [Dugsi_Manager Vaadin Application Servlet] in context with path [/Dugsi_Manager] threw exception [java.lang.UnsupportedOperationException] with root cause
java.lang.UnsupportedOperationException
    com.vaadin.ui.CustomComponent.addComponent(CustomComponent.java:218)
    com.vaadin.ui.Panel.addComponent(Panel.java:301)
    com.vaadin.ui.Window.addComponent(Window.java:281)
    org.bixin.dugsi.web.DugsiManagerApplication.init(DugsiManagerApplication.java:44)
    com.vaadin.Application.start(Application.java:554)
    com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1213)
    com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:359)
    org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:275)
    org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:344)
    org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:272)
    org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

这是我将对象添加到我的主应用程序类的方法:

//Thread Local to create instances of our application
private static ThreadLocal<DugsiManagerApplication> threadLocal = new ThreadLocal<DugsiManagerApplication>();
@Override
public void init() {
    setInstance(this); // immediate access to the app
    //Window homeWindow = createNewWindow();
    Subject currentUser = SecurityUtils.getSubject();
    // Create the URI fragment utility
    Window window = createLoginWindow();    

    setMainWindow(window);
    final UriFragmentUtility urifu = new UriFragmentUtility();
    window.addComponent(urifu);

}

在本教程中,它讨论了 URI 主要部分(地址 + 路径 + 可选查询参数),我的路径设置为 /Dugsi_Manager (web.xml) 是否应该在添加urifu对象后不启动https://localhost:8080/Dugsi_Manger#login

编辑:添加了 LoginWindow 的声明:

public Window createLoginWindow(){
     final Window loginWindow = new LoginWindow();

    //remove the window if closed to avoid memory leaks
    loginWindow.addListener(new CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            if (getMainWindow() != loginWindow) {
                DugsiManagerApplication.this.removeWindow(loginWindow);
            }
        }
    });
    return loginWindow;
}

\ ** 似乎UriFragmentUtility可以将对象添加到标准 Vaadin 窗口,但不适用于使用我的createLoginWindow函数创建的窗口?我不知道为什么?

4

1 回答 1

0

异常是由 CustomComponent 的 addComponent 方法引发的。所以我猜 CustomComponent 是一个窗口的内容。要解决此问题,请将 UriFragmentUtility 直接添加到作为 CustomComponent 的组合根的布局中,而不是

window.addComponent(urifu);
于 2012-01-24T07:36:33.363 回答