gpt4 book ai didi

vaadin - 强制 Vaadin 组件在不可见状态下占用它的空间

转载 作者:行者123 更新时间:2023-12-02 05:01:10 24 4
gpt4 key购买 nike

我的 Vaadin 指示器中有一个标签和一个进度指示器。它在 UI 中动态可见。此进度指示器下方有一棵树。

当程序动态地将 Progress Indicator 的可见性设置为 true 时,树会向下移动并且 UI 会因移动而抖动。

有什么方法可以让 Vaadin 组件占用它的空间,即使它是不可见的,因此,当它变得可见时,它不能尝试从其他 UI 组件借用空间?

我正在寻找的是类似于 flex 和 actionscript 编程中的 setRendered(true) 的功能。

感谢您的帮助。

最佳答案

我的问题终于有了答案。我只是用没有文本的虚拟可见标签替换了不可见的组件。

并交替使用它在可见和不可见之间切换。

asked the question in the Vaadin forum ,这是我从 Kim Leppanen 得到的回复:

With Vaadin 7, if you set a component's visibility to false, then the component's information is not sent to the browser at all - it is just as if the component wouldn't exist in the layout at all.

I can quickly come up with two solutions. If you know the size of the component whose visibility you want to toggle, then you can use placeholder components - such as a Label. Put a label with the correct size in the place where you want the component. When you want to set a component as visible, then replace the label with the actual component.

The second option is to use css. Apply the css attribute "visibility: hidden" for the component you want to hide. Note that the component is not "truly" hidden. Let's say that it is a button. A user could still inspect the DOM tree and see the button in the code, change the visibility of the component on the client side (eg using developer tools or firebug) and then see and use the button as if it would be visible in the layout.

我把它放在这里是因为人们可能会在那里添加一些更有用的答案。详细解释见this .

关于vaadin - 强制 Vaadin 组件在不可见状态下占用它的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17078864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com