Thanks ! Exactly.

Sandro Munda
<[email protected]>



On Tue, Mar 20, 2012 at 2:28 PM, Thomas Broyer <[email protected]> wrote:
>
> On Tuesday, March 20, 2012 12:49:10 PM UTC+1, Sandro Munda wrote:
>>
>> Hello everybody !
>>
>> I have a subclass of a JavaScriptObject with a generic type T.
>>
>> public class Foo<T> extends JavaScriptObject {
>>   // ...
>> }
>>
>> In this class, I have a getValue() method that returns a T value.
>>
>> private final native T getValue() /*-{
>>   return this.value;
>> }-*/;
>>
>> In my situation, T is an Integer. When I running the code I have the
>> following exception :
>>
>>  Caused by: java.lang.ClassCastException: Cannot cast
>> java.lang.Integer to com.google.gwt.core.client.JavaScriptObject
>>
>> Is the value is a 'int', it works well. But not the Integer.
>>
>> How can I fix the problem ?
>> Any workarrounds ?
>
> You cannot use Integer as a generic parameter in this case; you have to code
> specifically for the integer or other "primitive wrapper") case; something
> like:
>
> public final Integer getValue() {
>     return hasValue() ? Integer.valueOf(getValueInt()) : null;
> }
>
> private final native boolean hasValue() /*-{
>     return this.value == null;
> }-*/;
>
> private final native int getValueInt() /*-{
>     return Number(this.value);
> }-*/;
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/nrBiWtOwQqcJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to