nUIWebviewElement
com.softwareag.mobile.runtime.nui.nUIWebviewElement
Use to display rich Web content from a local or remote source. This Object allows the developer to pass messages between the Java code and the JavaScript runtime in the browser. For guidelines on how to approach this, see
JavaScript Bridge.
Usage Notes
The browser engines that mobile platforms use have differences in terms of how they display objects and support of JavaScript. You might need to develop platform-specific changes to support your content.
Mobile Designer does not change your raw HTML content.
Avoid invoking the Javascript
alert() method from inside a
nUIWebviewElement object. For security reasons, some manufacturers configure their devices to block displaying an alert dialog that results from a call to the Javascript
alert() call. As an alternative, consider one of the following:
Pass an event back to your Java code using a class that implements
nUIWebviewCallBack, which in turn can then open a
nUIAlertDialog object, if an alert dialog is required.
Use other web-based elements to display the alert information directly within your web page.
The Windows RT/Windows 8 platform does not support locally hosted images in a
nUIWebViewElement.There are two properties that react slightly differently depending on the platform.
bgcolor The bgcolor can be set at any time under iOS, and the web page will be redrawn to react to the change. Under Android, the changes to the bgcolor will only take affect when the webview redraws in response to changes in content (i.e. when the setURL() or setHTMLText() methods are called). For both platforms, the extent to which the web content is effected by this call is dependant on the rendering engine used in the browser itself, as well as the HTML content being displayed.
Scaling web content to fit This property is only usable on iOS. All other platforms ignore it. The setting will only affect page contents when the content of the page is changed (i.e. via setURL() or setHTMLText()).
There is currently no support for altering bgcolor, changing the scaling of content to fit or enabling/disabling overscrolling for Phoney or the C# platforms (Win Phone, RT).
Example
This code sample displays rich web content from a website. Illustrations of how the example code is rendered on various platforms follows the code sample.
nUIWebviewElement webelement =
new nUIWebviewElement(NUIID_MY_WEBVIEWELEMENT);
webelement.setHeight(250);
webelement.setURL("http://www.wikipedia.org/");
view.add(webelement);
Platform | Platform-Specific Class and Illustration |
Android | android.webkit.WebView |
iOS 7 | UIWebView |
iOS 6 | UIWebView |
Windows Phone | Microsoft.Phone.Controls.WebBrowser |
Windows RT Windows 8 | Windows.UI.Xaml.Controls.WebView |
Other | The nUIWebViewElement object is not supported when deployed on mobile devices, but will be provided through JavaFX (if available) when running in Phoney. |