[英]How can GWT 2.1 editor framework support primitive types?
I am trying to bind a field of the primitive type "int" to an editor. 我试图将原始类型“int”的字段绑定到编辑器。 My editor extends
ValueBox<Integer>
, since generics in Java can only use object types. 我的编辑器扩展了
ValueBox<Integer>
,因为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. 更改getter和setter以使用Integer对象,可以解决问题。 Is there any way to use a primitive type in the GWT 2.1 editor framework?
有没有办法在GWT 2.1编辑器框架中使用原始类型?
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, eg Integer
for int
. 唯一的方法是使用等效的对象类型,例如
Integer
for int
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.