How can GWT 2.1 editor framework support primitive types?
Asked Answered
S

2

7

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.

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 ""

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?

Sibella answered 14/11, 2010 at 8:36 Comment(0)
T
4

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

Thornie answered 14/11, 2010 at 11:17 Comment(2)
It is not clear that they will implement this in 2.1.1 - that bug only says that they will "clearly define" the behavior with primitives. What seems definite is that they'll make it fail with a more helpful error message. Jan, I think you should wrap your ints with Integers, and not wait for 2.1.1 to address this.Definitive
That is what we are going to do but it is a pity. A primitive cannot be null and we use that for non-nullable fields. Now we have to add that validation logic.Sibella
D
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.

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

Disquietude answered 14/11, 2010 at 9:37 Comment(0)
T
4

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

Thornie answered 14/11, 2010 at 11:17 Comment(2)
It is not clear that they will implement this in 2.1.1 - that bug only says that they will "clearly define" the behavior with primitives. What seems definite is that they'll make it fail with a more helpful error message. Jan, I think you should wrap your ints with Integers, and not wait for 2.1.1 to address this.Definitive
That is what we are going to do but it is a pity. A primitive cannot be null and we use that for non-nullable fields. Now we have to add that validation logic.Sibella

© 2022 - 2024 — McMap. All rights reserved.