Mobile Development 10.11 | webMethods Mobile SuiteWeb Help | webMethods Mobile Designer Native User Interface Reference | Mobile Designer Native User Interface | JavaScript Bridge | Sending a Message to Java from JavaScript
 
Sending a Message to Java from JavaScript
Sometimes, events inside the browser may require the support of additional Java code, either for speed or to add functionality. For this purpose, Mobile Designer provides an additional callback method in nUIWebviewCallbackExt that you can implement. This method is called onJavaScriptCallback(). After creating a nUIWebviewCallbackExt and associating it with a nUIWebView or nUIWebviewElement, this callback can be accessed through the JavaScript function MDInterface.javaScriptCallback(clazz, method, parameters). It is expected that clazz and method will be directly convertable from a JavaScript-style var into a java.lang.String, and the parameters argument will become an array of strings. On the Java side, you must implement the logic required to handle the onJavaScriptCallback() method. Calls coming from the JavaScript side will be routed directly to this method. Although the parameters passed suggest the use of class names and methods, this is not mandatory, and you can implement logic that differs from this pattern.