简体   繁体   English

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

[英]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

You need to wait for 2.1.1 for primitive types. 对于基本类型,您需要等待2.1.1。 There is an open bug tracking this. 有一个开放的bug跟踪这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM