gwt - JSNI - invoking native method from another native method -
how call native on button click of native method? can call more 1 native method single native method on button click
yes can it.
sample code:
public void onmoduleload() { exportsayhello(); button btn = new button("click"); btn.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { buttonclicked("vartika"); } }); rootpanel.get().add(btn); } public static native void exportsayhello() /*-{ $wnd.sayhellofunction = $entry(@com.gwt.test.client.gwttestproject::sayhello(ljava/lang/string;)); }-*/; public static native void buttonclicked(string value)/*-{ $wnd.sayhellofunction(value); }-*/; public static native void sayhello(string value)/*-{ $wnd.alert("hello " + value); }-*/;
steps follow:
- export method
sayhello()
javascript usingjsni
- now call native method
buttonclicked()
using same namesayhellofunction
exportedjavascript
.
read more gwt jsni.
Comments
Post a Comment