I am trying to call my Javascript method from my java in GWT below is what i am doing
public void onModuleLoad() {
jsniAlert("test");
}
private static final native void jsniAlert(String test) /*-{
$wnd.alert(test);
$wnd.testJavascript();
}-*/;
HelloJSNI.html (the main html class which use to open my application in war folder)
<script type="text/javascript" language="javascript"
src="hellojsni/hellojsni.nocache.js"></script>
<script type="text/javascript">
function testJavascript(var input) {
window.jsniAlert();
var var1inJS = "Default value";
alert("Value of Var1 = " + var1inJS);
var1inJS = input;
alert("Value of Var1 = " + var1inJS);
var var2inJS = "Waht is the value of Var2";
alert("Value of Var2 = " + var2inJS);
}
but when i run my application there's an exception
javascriptexception:object doesn't support property or method 'testjavascript'
You have an error in your testJavascript
function, so it is not getting loaded, and you can't call it.
Change this:
function testJavascript(var input) {
to this
function testJavascript(input) { //notice that var keyword is not used to define parameters