该面板不断获得位置:绝对应用。我怎样才能阻止它?

发布于 2024-09-28 15:58:49 字数 570 浏览 0 评论 0原文

我正在使用 AbsolutePanel 来做一些拖放之类的事情。我将子窗口小部件添加到 AbsolutePanel,然后使用absolutePanel.setWidgetPosition 设置它们的位置。

但我不断收到此错误:

java.lang.IllegalStateException:com.google.gwt.user.client.ui.AbsolutePanel 缺少 CSS 'position:{relative,absolute,fixed}'

堆栈跟踪直接指向 setWidgetPosition 调用。

但!我不仅已经调用了absolutePanel.getElement.getStyle().setPosition(Position.RELATIVE),而且还应用了带有position:relative 属性的样式名称。当我使用 FireBug 检查该元素时,它有一个带有“position:absolute”的样式属性,大概会覆盖其他所有内容。

我怎样才能摆脱这个警告?

实际的行为似乎工作正常,但也许我错过了一些东西。

I'm using an AbsolutePanel to do some drag-and-drop kind of stuff. I add child Widgets to the AbsolutePanel, and then use absolutePanel.setWidgetPosition to set their position.

But I keep getting this error:

java.lang.IllegalStateException: com.google.gwt.user.client.ui.AbsolutePanel is missing CSS 'position:{relative,absolute,fixed}'

the stack trace points right to the setWidgetPosition call.

BUT! Not only have I already called absolutePanel.getElement.getStyle().setPosition(Position.RELATIVE), I have also applied a style name with a position: relative attribute. When I inspect the element with FireBug, it has a style attribute with "position: absolute" right in it, presumably overriding everything else.

How can I get rid of this warning?

The actual behavior seems to be working fine, but maybe I'm missing something.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

身边 2024-10-05 15:58:49

不确定这个错误是否真的得到修复,因为我在 GWT 2.6.0 中仍然遇到这个问题。

查看 AbsolutePanel 的代码,我注意到当子元素从 AbsolutePanel 中删除时,它会清空子元素的位置属性值。
当子项重新添加到 AbsolutePanel 时,位置属性仍为空。
如果重新添加的子级本身是 AbsolutePanel,则这是有问题的,因为在这种情况下,在子 AbsolutePanel 上调用 setWidgetPosition 时会发生 IllegalStateException 异常。

当你在做一些拖拽时删除通常与添加/删除小部件一起出现的内容,我认为这就是发生的事情。

解决方法:
从其父 AbsolutePanel 中删除 myChildAbsolutePanel 后立即调用 myChildAbsolutePanel.getElement().getStyle().setProperty("position", "relative")

远非美丽 - 但对我有用。

Not sure, if this bug actually got fixed as I'm still experiencing this problem with GWT 2.6.0.

Looking into the code of AbsolutePanel I noticed that it empties the value of the position attibute of a child element when it is removed from the AbsolutePanel.
When the child is re-added to the AbsolutePanel the position attribute remains empty.
This is problematic, if the re-added child itself is an AbsolutePanel, because in this case an IllegalStateException exception occurs when setWidgetPosition is called on the child AbsolutePanel.

As you were doing some drag & drop stuff which usually goes along with adding / removing widgets I assume this is what has happened.

Workaround:
Call myChildAbsolutePanel.getElement().getStyle().setProperty("position", "relative") right after removing myChildAbsolutePanel from its parent AbsolutePanel.

Far from being beautiful - but works for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文