获取Vaadin中组件的正确宽度和高度 [英] Get the exactly width and height of a component in Vaadin
问题描述
如果我使用sizeful(),我会得到100%。但是,我怎样才能得到组件的正确宽度和高度呢?
在Vaadin中,布局由客户端浏览器中的引擎和布局组件的具体大小通常取决于浏览器窗口的大小。组件大小不会通过Vaadin标准组件发送回服务器。
由于您的所有代码都是在服务器上执行的,因此它也无法获取这些值。您需要编写一个特殊的包装器组件,每次更改时都会将其大小发送回服务器。
更新2013-03-21:我为Vaadin 7开发了 SizeReporter插件,它将组件的大小发送回服务器,并在大小发生变化时通知您。
In vaadin, if I set width and height to undefined, I will get -1 when using getHeight()/getWidth() function. if I use sizeful(), I will get 100%. But how can I get the exactly width and height of a component?
In Vaadin, the layout is realized by the client side engine in the browser and the concrete sizes of layout components usually depend on the size of the browser window. Component sizes are not sent back to the server by the Vaadin standard components.
Since all of your code is executed on the server, it cannot get at those values, either. You would need to program a special wrapper component that sends its size back to the server each time it changes.
Update 2013-03-21: I have developed the SizeReporter add-on for Vaadin 7 which sends back the size of the component to the server and notifies you when the size changes.
这篇关于获取Vaadin中组件的正确宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!