无法让 SplitLayoutPanel 工作 - GWT + UIBinder 让我发疯
...
<g:VerticalPanel styleName="{style.mainVerticalPanel}">
<g:SplitLayoutPanel>
<g:north size="700">
<g:VerticalPanel>
<g:ScrollPanel styleName="{style.conversationPanelContainer}">
<g:FlexTable ui:field="conversationPanel" styleName="{style.conversationPanel}"></g:FlexTable>
</g:ScrollPanel>
<g:HorizontalPanel styleName="{style.messageTextAndSendPanel}">
<g:TextBox ui:field="messageText" styleName="{style.messageText}"></g:TextBox><g:Button ui:field="sendButton">Send</g:Button>
</g:HorizontalPanel>
</g:VerticalPanel>
</g:north>
<g:south size="300">
<g:button>TestButton</g:button>
</g:south>
</g:SplitLayoutPanel>
</g:VerticalPanel>
...
这看起来有什么问题吗?我想做的就是制作一个简单的分割面板,但每当我运行它时,我得到的只是一个空白页面。没有任何 SplitPanel
东西,它工作得很好。 DockLayoutPanel
也会发生同样的情况。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,让它工作了(有关以前的尝试,请参阅此答案的旧版本;))。
我的解决方案基于 邮件示例。
工作代码:
UiBinder *.ui.xml:
请注意一些事项:
,而不是RootLayoutPanel
而不是通常的RootPanel
还是有点困惑LayoutPanel
的东西 - 在 邮件示例 他们使用嵌套在DockLayoutPanel
中的SplitLayoutPanel
,但仅DockLayoutPanel
显式添加到RootLayoutPanel
- 我是否理解SplitLayoutPanel
也会自动添加(以便它可以接收调整大小事件, ETC)?嵌套在主 LayoutPanel 中的其他一些 Widget 怎么样 - 它们是否必须显式添加到 RootLayoutPanel 中,或者仅当它们是该 Widget/Composite 的根时,或者甚至不可能?我真的没有时间进一步追求这个 - 我会把它作为其他人的家庭作业;)顺便说一句:我已经在怪异模式和标准模式下检查了这段代码 - 我没有看到区别,两者work O_o(不过,这是
SplitLayoutPanel
的简单使用 - 更复杂的示例可能会导致 Quirks 模式中的一些奇怪行为和/或渲染错误)OK, got it working (see older versions of this answer for previous attempts ;)).
My solution is based on Mail example.
The working code:
UiBinder *.ui.xml:
Note a number of things:
<g:Button>
, not<g:button>
(case sensitive)RootLayoutPanel
instead of the usualRootPanel
LayoutPanel
s thingy - in the Mail example they use aSplitLayoutPanel
nested in aDockLayoutPanel
, yet only theDockLayoutPanel
is explicitly added to theRootLayoutPanel
- am I to understand that theSplitLayoutPanel
automagically also gets added (so that it can receive resize events, etc)? How about some other Widgets nested in the main LayoutPanel - do they have to be explicitly added to theRootLayoutPanel
or only if they are the root of that Widget/Composite or is that not even possible? I don't really have time atm to pursue this further - I'll leave it as a homework for someone else ;)BTW: I've checked this code under Quirks mode and Standards mode - I don't see a difference, both work O_o (though, this is a simple use of the
SplitLayoutPanel
- more complex examples will probably result in some weird behavior in Quirks mode and/or rendering errors)您使用哪种文档类型?这些面板仅在标准模式下工作(至少对于某些浏览器)。如果您使用怪异模式,那么经常会发生这些面板出现空白页面的情况。
检查您的 HTML 文件。理想情况下,它应该以以下内容开头:
或者其他一些导致标准模式的文档类型(但请确保以 100% 逐字输入),请参阅 http://hsivonen.iki.fi/doctype/
Which doctype are you using? These panels only work in standards mode (at least with some broswers). If you use quirks mode, then it often happens, that you get a blank page with these panels.
Check your HTML file. It should ideally start with:
Or alternatively some other doctype that results in standards mode (but make sure to type it in 100% verbatim), see http://hsivonen.iki.fi/doctype/