The Mobile & Digital Assistant Blog covers the latest in mobile and conversational AI development and engagement

Opening a web link from your MAF app in the device browser app

Graeme Mawson
Senior Principal Product Manager
We've recently received a few inquiries about how to display a web link in a MAF app that will open in the device’s browser app when the user taps on it.

It seems that some teams have been relying on a side effect of whitelisting to circumvent the default MAF behaviour, which is to display the contents of the web link directly in the current WebView.  In earlier releases of MAF, if you did not add the web link’s URL to the whitelist, it would be opened in the device’s browser app instead.  However, with recent changes to Cordova and MAF whitelist functionality, this is no longer the case.  

This was never really the correct way to do it anyway, so what is the correct way?

InAppBrowser plugin
The Apache Cordova team has kindly provided a plugin called cordova-plugin-inappbrowser that gives you complete control over how the web link should be displayed.
You can find full documentation about this plugin in the Cordova documentation.
How do I use this in my MAF app?
First, you need to add the plugin to your MAF app as follows:
1. Download the plugin from GitHub
2. Extract the contents of the downloaded zip file into your MAF app’s source code (preferably in the top-level src folder)
3. Add the plugin to your MAF app’s maf-application.xml file via the Plugins UI in JDeveloper
Next, add a link to your page that invokes a custom JavaScript function as follows:
1. Drag a Link (<amx:commandLink>) onto your page
2. Edit the Action Listener property of this link by creating a new Managed Bean with a single method
3. Modify the newly created bean’s method to invoke a custom JavaScript function as follows:    
    AdfmfJavaUtilities.getFeatureId(), "displayLink", new Object[] { });
Finally, create the custom JavaScript file and add it to your app, as follows:
1. Create a new JavaScript file within the feature into which you’ve added the link
2. Modify this JavaScript file to include the referenced function as follows (specifying your desired URL):  
(function () {
    displayLink = function() {
        cordova.InAppBrowser.open('http://www.oracle.com', '_system');
}) ();
3. Add the newly created JavaScript file to your feature’s content via the maf-feature.xml file.
The MAF Developer Guide provides detailed information about how to complete each of the steps listed above.
Having completed these steps, deploy to a device or simulator/emulator for testing.


Do not use whitelisting in an attempt to force your MAF app to display an external web link in the device's browser app.

Whitelisting should only be used to secure references to external web links that are displayed within the current WebView of your MAF app.

Use the cordova-plugin-inappbrowser plugin supplied by the Apache Cordova team to control the display of external web links from your MAF app. 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.

Recent Content