如何清理/删除vaadin 14中applayout中的内容?

w6lpcovy  于 2021-07-08  发布在  Java
关注(0)|答案(1)|浏览(486)

如何显示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:

错误是:

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

所以我需要清理房间 `content` 第一。在瓦丁14号我怎么能做到?
nfg76nw0

nfg76nw01#

该错误已在一定程度上说明了问题: Can't move a node from one state tree to another 或者更确切地说:您不能在不同的ui上共享元素。所以没有 static ,没有单例,…-你必须创造新的元素。
元素一旦被附加,就会成为一个ui(错误消息中的状态树)的场景图的一部分。此时,vaadin内部构件确保元素尚未附加到不同的ui(root)(可以在一个ui中移动元素,这也可以通过将元素添加到同一ui的不同父级来实现)。
如果在服务器上共享状态,则必须为每个ui创建元素,然后将此状态与同步 @Push 以及 UI.access 或者类似的。

相关问题