0

我目前正在使用 MVP 模式使用 Vaadin Flow (v11.0.0) 和 Spring Boot (v2.0.4) 开发应用程序。该应用程序工作正常,只要它只在一个选项卡中打开。重新加载时刷新整个页面,这完全没问题。同样在第二个选项卡或窗口中打开它(不管是否隐身)都可以正常工作。但是,当我在一个窗口中单击某些内容,然后在另一个窗口中单击时,会发生以下错误:

java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.
at com.vaadin.flow.server.VaadinSession.checkHasLock(VaadinSession.java:515) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.server.VaadinSession.checkHasLock(VaadinSession.java:529) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.internal.StateTree.checkHasLock(StateTree.java:390) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.internal.StateTree.markAsDirty(StateTree.java:258) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.internal.StateNode.markAsDirty(StateNode.java:326) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.internal.nodefeature.NodeValue.markAsDirty(NodeValue.java:85) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.internal.nodefeature.NodeValue.setValue(NodeValue.java:78) ~[flow-server-1.0.5.jar:na]
at com.vaadin.flow.internal.nodefeature.TextNodeMap.setText(TextNodeMap.java:52) ~[flow-server-1.0.5.jar:na]

我只有一个视图(因此也是演示者),我这样注释:

@Route(value = LogAnalysis.route)
@PageTitle(LogAnalysis.name)
class LogAnalysisView(val presenter: LogAnalysis.ViewPresenter) : VerticalLayout(), LogAnalysis.View, BeforeEnterObserver { ... }

@Component
@UIScope
@VaadinSessionScope
class LogAnalysisPresenter(val service: LogAnalysis.Service) : LogAnalysis.ServicePresenter, LogAnalysis.ViewPresenter { ... }
4

1 回答 1

0

我也设法通过向@UIScope服务(模型)添加注释来解决这个问题。

我假设该服务可以是单例的,因为它只是从数据库中获取和准备数据,但是该服务持有对演示者的引用,每次创建新会话时都会覆盖该引用。

于 2018-09-20T12:14:26.867 回答