GWT 2.1编辑器框架如何支持原始类型?

时间:2022-09-11 19:17:14

I am trying to bind a field of the primitive type "int" to an editor. My editor extends ValueBox<Integer>, since generics in Java can only use object types.

我试图将原始类型“int”的字段绑定到编辑器。我的编辑器扩展了ValueBox ,因为Java中的泛型只能使用对象类型。

When I compile my application, I get the following error:

当我编译我的应用程序时,我收到以下错误:

00:00:18,915 [ERROR] Found unexpected type int while evauating path "cadastralDivisionCode" using getter expression ""

00:00:18,915 [ERROR]在使用getter表达式“”唤醒路径“cadastralDivisionCode”时发现意外类型int

Changing the getter and the setter to use an Integer object, does the trick. Is there any way to use a primitive type in the GWT 2.1 editor framework?

更改getter和setter以使用Integer对象,可以解决问题。有没有办法在GWT 2.1编辑器框架中使用原始类型?

2 个解决方案

#1


4  

You need to wait for 2.1.1 for primitive types. There is an open bug tracking this.

对于基本类型,您需要等待2.1.1。有一个开放的bug跟踪这个。

#2


4  

Haven't looked at GWT internals, but most probably it can't be done, because primitive values are not handled by reference and can not be put into Collections.

没有看过GWT内部,但很可能无法完成,因为原始值不是通过引用处理的,也不能放入集合中。

The only way around is to use equivalent object types, e.g. Integer for int.

唯一的方法是使用等效的对象类型,例如int的整数。

#1


4  

You need to wait for 2.1.1 for primitive types. There is an open bug tracking this.

对于基本类型,您需要等待2.1.1。有一个开放的bug跟踪这个。

#2


4  

Haven't looked at GWT internals, but most probably it can't be done, because primitive values are not handled by reference and can not be put into Collections.

没有看过GWT内部,但很可能无法完成,因为原始值不是通过引用处理的,也不能放入集合中。

The only way around is to use equivalent object types, e.g. Integer for int.

唯一的方法是使用等效的对象类型,例如int的整数。