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 developers 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, the developer will need to 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 set in stone, and the developer may wish to implement logic that differs from this pattern.