gpt4 book ai didi

vaadin - 强制 Vaadin 组件以不可见状态占据其空间

转载 作者:行者123 更新时间:2023-12-02 22:00:17 25 4
gpt4 key购买 nike

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

当程序动态地将进度指示器的可见性设置为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/

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