I am using GWT 2.8.0-SNAPSHOT, but the new annotations does not work for me.

I tried using @JsType(namespace = "acme", name = "MyJavaScriptObject"), as 
described in the new version of the JsInterop document, but apparently the 
namespace and name attributes are not there in the jar file.
Same thing with the @JsExport and @JsNamespace, I currently have to use 
them or things stop working.

My gwt-user-2.8.0-SNAPSHOT.jar, which contains the annotations, is from 
today.

This is the pom I am using: 
https://github.com/bitwerk/jspoc/blob/master/pom.xml

/Brian
 
Den mandag den 26. oktober 2015 kl. 11.43.32 UTC+1 skrev Thomas Broyer:
>
> You may want to use GWT 2.8.0-SNAPSHOT and the new JsInterop annotations; 
> as your usecase maybe is just not supported with the "old" annotations.
>
> On Monday, October 26, 2015 at 11:10:28 AM UTC+1, Brian Pedersen wrote:
>>
>> I have a dispatch method, exposed through JsInterop, which can take 
>> various kinds of payloads.
>>
>> Once called from native javascript, I need to cast the payload, but this 
>> doesn't quite work as I would like it too.
>>
>> Here is a simplified example.
>>
>> *GWT:*
>> @JsExport
>> @JsType
>> @JsNamespace("foo")
>> public class Dispatcher {
>> public String dispatch(String action, Payload payload){
>> if("action1".equals(action))
>> return dispatchWithCast(payload);
>> return "Unknown action: " + action;
>> }
>> public String dispatchWithCast(Payload payload){
>> ConcretePayload w = (ConcretePayload) payload;
>> return w.foo;
>> }
>> }
>>
>> @JsExport
>> @JsType
>> public class Payload {}
>>
>> @JsExport
>> @JsType
>> public class ConcretePayload extends Payload {
>> public String foo;
>> public int bar;
>> }
>>
>> *Javascript:*
>> var test = new foo.Dispatcher();
>> alert("Dispatch: " + test.dispatch("action1", {"foo": "a", "bar": 2})); 
>> // Uncaught java.lang.ClassCastException
>>
>> Everything works just fine if I replace the Payload type in the 
>> Dispatcher class with ConcretePayload, and removes the cast.
>>
>> I guess this this may be beyond the capabilities of the transpiler, I 
>> just need to figure out an alternative approach.
>>
>> Any ideas?
>>
>> (By the way, I am using the sso linker.)
>>
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to