编辑器,UiBinder和从Integer到String的自动映射

时间:2013-05-02 08:10:11

标签: gwt

我有一个基本对象,它有3个属性:

  • id:整数
  • width:Integer
  • 身高:整数

我需要一个编辑器才能使高度宽度可编辑,我还想在标签中显示 id

问题是标签接受字符串,而标识是整数。所以,如果我尝试以下内容:

  @UiField
  Label id;

我有这个错误:

[ERROR] Line 17: Type mismatch: cannot convert from Integer to String

我可以使用以下代码解决此问题:

@UiField
@Ignore
Label myId;

...

void setId(Integer id){
    this.myId.setText(""+id);
}

但这意味着当我编辑()编辑器时我必须手动调用setId()。

有没有办法在设置id时自动更新标签文本?

1 个答案:

答案 0 :(得分:5)

使用NumberLabel而不是Label