Monday, April 11, 2016

Re: @JsFunction transmitted from java to javascript using JsInterop

Yes, I have tried that way, but no result.
The itemList (menu in your code sample) is a JsArray and it accepts only
JavaScriptObjects (there are 2 methods for adding items, push and set). So,
I can't add to it a "new Item(...)" even if it is a @JsType because it
requires JavaScriptObject.

*Later edit:* while writing the above response, I have remembered that I saw
in Julien Dramaix's JsInterop Deep Dive, the JsArray wrapped in java with
@JsType(isNative=true).
"@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Array")
public class JsArray<T> {
public native void push(T item);
}"

Using this, I am able to add a new Item to the itemList, and the passed
function is recognized in javascript.

Case solved, thank you.



--
View this message in context: http://google-web-toolkit.2317884.n4.nabble.com/JsFunction-transmitted-from-java-to-javascript-using-JsInterop-tp15596p15599.html
Sent from the Google Web Toolkit mailing list archive at Nabble.com.

--
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 https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment