Although GWT code is written in Java instead of JavaScript, sometimes you need to write code that can make direct JavaScript calls. The JavaScript Native Interface(JSNI) lets you execute javaScript from Java as wll as execute Java from Java Script.
Following example passes a Java List object to the method and uses JavaScript to
add two items to it:
public native void fillData (List data)
/*-{
data.@java.util.List::add(Ljava/lang/Object;)('item1');
data.@java.util.List::add(Ljava/lang/Object;)('item2');
}-*/;
Following example passes a Java List object to the method and uses JavaScript to
add two items to it:
public native void fillData (List data)
/*-{
data.@java.util.List::add(Ljava/lang/Object;)('item1');
data.@java.util.List::add(Ljava/lang/Object;)('item2');
}-*/;
WTF!! Works very well, thank you very much!
ReplyDelete