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

Arn*_*lle 1 gwt

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

  • id:整数
  • width:整数
  • 高度:整数

我需要一个编辑器来使高度宽度可编辑,我还想在Label中显示id.

问题是Label接受一个String而id是一个Integer.所以如果我尝试以下方法:

  @UiField
  Label id;
Run Code Online (Sandbox Code Playgroud)

我有这个错误:

[ERROR] Line 17: Type mismatch: cannot convert from Integer to String
Run Code Online (Sandbox Code Playgroud)

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

@UiField
@Ignore
Label myId;

...

void setId(Integer id){
    this.myId.setText(""+id);
}
Run Code Online (Sandbox Code Playgroud)

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

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

Tho*_*yer 5

使用NumberLabel而不是Label.