2

我希望我的表具有以下静态列标题:“姓名”、“姓氏”、“出生日期”,但我想在 *.ui.xml 中声明它们(而不是在代码中)。

现在,我正在通过这样的代码进行操作:

public PersonViewImpl extends Composite implements PersonView {
    /*Lots of code removed for clarity*/

    @UiField (provided = true) FlexTable personTable;

    public PersonViewImpl(){
        personTable.setText(0, 0, "Name");
        personTable.setText(0, 1, "Surname");
        personTable.setText(0, 2, "DOB")    
    }
}

我的 PersonView.ui.xml 中有这个

<g:FlexTable ui:field="personTable" />

我已经用谷歌搜索了几个小时,但仍然没有去。

4

3 回答 3

2

您不能在 UI Binder 中设置 FlexTable 的单元格元素,可能您应该拥有自己的自定义小部件来呈现 tr 和 td。例如,就像这里解释的:GWT table row as UiBinder

于 2012-01-25T06:24:32.920 回答
1

当您声明时provider = true,ui binder 没有实例化该对象,您需要在您的 java 类中实例化它,正确的代码是:

public PersonViewImpl(){
    // enter code here
    personTable = new FlexTable();
    personTable.setText(0, 0, "Name");
    personTable.setText(0, 1, "Surname");
    personTable.setText(0, 2, "DOB");
}
于 2012-07-11T08:32:58.250 回答
0

缺少initWidget( uiBinder.createAndBindUi(this) );构造函数的第一行。

尝试这个:

public class PersonViewImpl extends Composite implements PersonView {
    /*Lots of code removed for clarity*/

    @UiField (provided = true) FlexTable personTable;

    public PersonViewImpl(){
        initWidget( uiBinder.createAndBindUi(this) );
        // TODO your code
    }
}
于 2013-08-17T02:50:36.913 回答