在视图之间导航时,如何保留vaadin视图实例
我有一个包含大量数据的视图。数据在视图初始化时加载。现在,当我使用 Router 离开视图然后返回视图时,会创建一个新的视图实例,从而触发重新获取所有数据。即使返回视图时,我也想保留原始视图实例 - 如何实现?
编辑: 添加细节,这是一个 Spring Boot 应用程序,与我的预期不同,将视图注释为 @UIScope 并没有保留实例,但每次导航到视图时都会创建一个新实例。
I have a view which is quite heavy with data. The data is loaded when the view is initialized. Now, when I navigate away from the view using Router and then return to the view, a new view instance is created triggering refetching of all the data. I would like to preserve the original view instance even when returning to the view - how can this be achieved?
Edit:
To add details, this is a Spring Boot application and unlike to my expectation, annotating a view as @UIScope didn't keep the instance, but a new instance was created every time when navigating to the view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人遇到相同的情况,请回答我自己的问题。
我有一个Spring Boot应用程序,因此第一步是定义视图的范围,以免重新创建它们,合适的范围是Uiscope。但是,这还不够,即使注入豆类在框外工作,默认情况下,视图似乎并不是管理bean,因此将@component注释添加到视图中使它们受到管理,因此, @ @ @ Uiscope范围也开始工作。
Answering my own question, in case someone else runs into the same situation.
I had a Spring Boot application, so the first step was to define the scope for the views so that they wouldn't be recreated, a suitable scope is UIScope. However, that is not enough, even though injecting of beans work out-of-the-box, the views don't seem to be managed beans by default, so adding @Component annotation to the view makes them managed and thus, the @UIScope scoping also starts working.