我正在做我的第一个GWT项目,但在使用UiBinder时遇到了一些麻烦。当我加载我的模块时,甚至连HTML都没有显示,我只看到一个空白页面。有人知道为什么吗?我遗漏了什么?
我还没有掌握面板的概念,RootPanel就是ScrollPanel吗?还是mainPanel,因为我给了它一个标识符?
编辑:我遇到错误:这个面板不支持no-arg add。但是这个错误并没有说明是哪一个。关于如何获得我想要的布局有什么建议吗?
提前谢谢。
UiBinder类DoraTheExplora.ui.xml:
<g:ScrollPanel>
<g:VerticalPanel ui:field="mainPanel">
<!-- Header of Dora website -->
<g:HorizontalPanel ui:field="headerPanel">
<g:HTMLPanel styleName="{resource.style.siteHeader}">
Welcome to Dora!
</g:HTMLPanel>
...EntryPoint类:
...
public void onModuleLoad() {
RootLayoutPanel.get().add(new DoraTheExplora());
}
...DoraTheExplora类:
...
public class DoraTheExplora extends Composite {
// UIBinder instance.
@UiTemplate("DoraTheExplora.ui.xml")
interface DoraTheExploraUiBinder extends UiBinder<Widget, DoraTheExplora> {
}
private static DoraTheExploraUiBinder uiBinder = GWT.create(DoraTheExploraUiBinder.class);
@UiField
VerticalPanel mainPanel;
@UiField
HorizontalPanel headerPanel;
...
public DoraTheExplora() {
initWidget(uiBinder.createAndBindUi(this));
...
}
}发布于 2013-06-15 09:48:16
我想通了。我在ui.xml文件中嵌套了一个FlexTable,它抛出了no-args错误。
我认为这与根面板有关,但我错了。如果有人还想向我解释根面板的概念,那将非常感谢!
发布于 2022-01-27 19:47:33
GWT RootPanel是所有其他小部件都附加到的起始面板或最上面的面板。RootPanels永远不会直接创建。相反,可以通过get()或get(id)访问它们。
我更喜欢放在根html上。然后,
public void onModuleLoad() {
RootPanel.get("main_port").add(maincontainer);
---https://stackoverflow.com/questions/17119070
复制相似问题