nUIWebView
com.softwareag.mobile.runtime.nui.nUIWebView
Use to create a container for the
nUIWebviewElement object, which is an object that allows for the display of rich web content. 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
nUIWebView 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
nUIWebView.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 creates a Web view with navigation to the parent menu. Illustrations of how the example code is rendered on various platforms follows the code sample.
protected nUIViewDisplay onCreateWebView()
{
nUIWebView web_view = new nUIWebView(NUIID_WEB_VIEW);
web_view.setHeadertext("nUIWebView");
web_view.setURL("http://www.wikipedia.org/");
nUINavbuttonElement ne = new nUINavbuttonElement(NUIID_BACK_TO_START_BUTTON,
"Back",
nUINavbuttonElement.TYPE_BACK, null);
web_view.add(ne);
return web_view;
}
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 nUIWebView object is not supported when deployed on mobile devices, but will be provided through JavaFX (if available) when running in Phoney. |