Vaadin 23:MainView 中的 ScopeNotActiveException,扩展了 AppLayout View

发布于 2025-01-14 09:57:19 字数 1239 浏览 4 评论 0原文

我有以下视图结构:

主页

@SpringComponent
@UIScope
@PageTitle("ExampleApp: Home Page")
@Route(value = Endpoint.UI.HOME_PAGE, layout = MainView.class)
public class HomePage extends VerticalLayout {
  //the rest is ommited
}

几个像这样的其他页面和 MainView

@SpringComponent
@UIScope
@Push
@Viewport("width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes")
//@PWA - details ommited
@Theme(themeClass = Lumo.class, variant = Lumo.DARK)
@CssImport("./css/main_view.css")
public class MainView extends AppLayout implements BeforeEnterObserver, AppShellConfigurator {
   //implementation is ommited. 
}

在 Vaadin 14.8.1 应用程序中运行完美。但更新到 Vaadin 23.0.1 后,我得到:


2022-03-14T09:39:07.191902382Z org.springframework.beans.factory.support.ScopeNotActiveException: Error creating bean with name 'mainView': 

Scope 'vaadin-ui' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton;

 nested exception is java.lang.IllegalStateException: There is no UI available. The UI scope is not active

问题:如何从 MainView 访问 UI 范围或对象?

I have following Views structure:

Home Page

@SpringComponent
@UIScope
@PageTitle("ExampleApp: Home Page")
@Route(value = Endpoint.UI.HOME_PAGE, layout = MainView.class)
public class HomePage extends VerticalLayout {
  //the rest is ommited
}

few another pages like this and MainView:

@SpringComponent
@UIScope
@Push
@Viewport("width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes")
//@PWA - details ommited
@Theme(themeClass = Lumo.class, variant = Lumo.DARK)
@CssImport("./css/main_view.css")
public class MainView extends AppLayout implements BeforeEnterObserver, AppShellConfigurator {
   //implementation is ommited. 
}

In Vaadin 14.8.1 App works perfectly. But after updating to Vaadin 23.0.1 I got:


2022-03-14T09:39:07.191902382Z org.springframework.beans.factory.support.ScopeNotActiveException: Error creating bean with name 'mainView': 

Scope 'vaadin-ui' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton;

 nested exception is java.lang.IllegalStateException: There is no UI available. The UI scope is not active

Question: how do I access UI Scope or Object from MainView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文