Thursday, October 29, 2015

Re: JsInterop: Casting native javascript objects in gwt

You can only implement java contract (e.g. PayLoad class) in javascript if they are marked as isNative. See the related section in the new jsinterop doc.

On Mon, Oct 26, 2015 at 5:01 AM, Brian Pedersen <brian.pedersen@gmail.com> wrote:
Thank's for pointing that out. So i switched to the new annotations in jsinterop.annotations and activated the new mode with -jsInteropMode JS_RC.

The cast still doesn't work though :(

Instead of a java.lang.ClassCastException, I now get a  Uncaught [object Object] during the cast.
Once again, everything works if I use the concrete type and remove the cast.


/Brian


Den mandag den 26. oktober 2015 kl. 12.29.21 UTC+1 skrev Jens:

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.

The new annotations have a different package: jsinterop.annotations. Also @JsExport does not exist anymore in the new JsInterop version, you just use @JsType.

To activate the new annotations you also have to change the JsInterop mode via -jsInteropMode JS_RC


-- J.

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment