【问题标题】:MVP - What adjustment must be made to enable a "UiField FlowPanel" to work (rather than "UiField SimplePanel"?MVP - 必须进行哪些调整才能使“UiField FlowPanel”工作(而不是“UiField SimplePanel”?
【发布时间】:2011-03-16 19:10:55
【问题描述】:

我将“topPanel”UiField 更改为引用 FlowPanel 而不是 SimplePanel。
--但是,当我这样做时,我的“视图”类中原来的“setWidget”方法不再有效。

我可以进行哪些调整(如果可以进行)以使 FlowPanel "@UiField" 能够正确编译和处理?

这里是“视图”类...

    public class TopPanel extends Composite implements AcceptsOneWidget 
    {
    -
    -
    -
    //...prev...@UiField
    //...prev...SimplePanel topPanel;

    //...Trying to make this work...
    @UiField
    FlowPanel topPanel;    
    -
    -
    -
    //...how should this method be modified or replaced to allow the FlowPanel "@UiField" to work?....
    @Override
    public void setWidget(IsWidget w)
    {
        topPanel.setWidget(w);
    }    
}

这里是 uiBinder 模板...

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
    <ui:style src="app.css" />
    <g:HTMLPanel width="50%" height="50%">
        <!--  <g:SimplePanel ui:field="topPanel"> -->   
        <g:FlowPanel ui:field="topPanel">
            <g:Button text="from aaa: go to bbb" ui:field="topButtonA"></g:Button>
            <g:Button text="from bbb: go to ccc" ui:field="topButtonB"></g:Button>
            <g:Button text="from ccc: go to aaa" ui:field="topButtonC"></g:Button>
        </g:FlowPanel>
    </g:HTMLPanel>
</ui:UiBinder>

【问题讨论】:

  • 您看到的具体异常或错误是什么?
  • "未定义 FlowPanel 类型的 setWidget(IsWidget) 方法"

标签: gwt mvp uibinder


【解决方案1】:

尝试:

topPanel.insert(w,0)

而不是

topPanel.setWidget(w)

【讨论】:

  • 其实“view”类叫做“TopPanel”。 “TopPanel.ui.xml”包含一个名为“topPanel”的标签(我猜这很混乱),它对应于“TopPanel”视图类中的“@UiField topPanel”。
  • [续] ...“TopPanel”视图类定义为“公共类 TopPanel 扩展 Composite 实现 AcceptsOneWidget”...此定义所需的实现方法之一是“setWidget” .当我将“@UiField”从“SimplePanel”更改为“FlowPanel”时,IDE(或编译器)不允许使用“topPanel.setWidget(w)”......我将尝试“topPanel.insert”并让你知道会发生什么...--谢谢你的帮助
  • topPanel 是 Fl​​owPanel 的名称,如代码中的 @UiField 和 ui:field 所示。
【解决方案2】:

如果您想在 topPanel 中包含的按钮下方/之后添加小部件,您应该使用:

topPanel.add(w)

【讨论】:

    猜你喜欢
    • 2011-05-07
    • 2016-10-02
    • 1970-01-01
    • 2011-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多