MrY*_*Yui 0 java vaadin vaadin14
如何在 Vaadin 14 中显示静态组件?每次更新页面时,我都会收到错误消息。
在这种情况下,startStopYOLO, cameras, darknet, configuration, weights, thresholds, realTimeCameraImage, layout都是static
// Content
if(layout == null) {
layout = new VerticalLayout();
layout.add(new FormLayout(startStopYOLO, cameras, darknet, configuration, weights, thresholds));
layout.add(realTimeCameraImage);
layout.setAlignItems(Alignment.CENTER);
}
setContent(layout); // Here I get the error:
Run Code Online (Sandbox Code Playgroud)
错误是:
Can't move a node from one state tree to another. If this is intentional, first remove the node from its current state tree by calling removeFromTree
Run Code Online (Sandbox Code Playgroud)
所以我需要清理第content一个。我怎样才能在 Vaadin 14 中做到这一点?
该错误已经在某种程度上说明了问题: Can't move a node from one state tree to another
或者更确切地说:您不能在不同的 UI 上共享元素。所以不
static,没有单身人士,...... - 你必须创造新的元素。
元素 一旦被附加,就会成为一个 UI 场景图的一部分(错误消息中的状态树)。此时,Vaadin 内部结构确保该元素尚未附加到不同的 UI(根)(可以在一个 UI 内移动元素,这也可以通过将其添加到同一 UI 的不同父级来实现)。
如果您通过例如服务器共享状态,您将必须为每个 UI 创建元素,然后与@Push和
UI.access或类似的同步此状态。