Building Mobile Enterprise Applications : webMethods Mobile Designer Native User Interface Reference : Mobile Designer Native User Interface : JavaScript Bridge : Sending a message to JavaScript from Java
Sending a message to JavaScript from Java
Messages are sent using the callJavaScript() method on the nUIWebView or nUIWebviewElement. The developer needs to specify the name of a JavaScript function to call, and an array of java.lang.String objects for the functions's arguments. If no arguments are required, a String array of length 0 should be used. Example for two JavaScript functions, myFirstMethod() and mySecondMethodWithArgs(param1, param2):
//call myFirstMethod() to do something
myWebView.callJavaScript("myFirstMethod", new String[]{});
//call mySecondMethodWithArgs with "one" and "two" as arguments
myWebView.callJavaScript("mySecondMethodWithArgs", new String[]{"one", "two"});
Using callJavaScript() in this manner will cause execution on the Java side to wait for a return value. It is also possible to pass an additional parameter to callJavaScript() that will allow the JavaScript function to return a String value to Java. Pass in a reference to a class that implements the NativeUI interface com.softwareag.mobile.runtime.nui.IJSCallback.
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback