Calling the Hybrid Web Container

It is easiest to learn how to call the Hybrid Web Container by examining the API.js and Utils.js files, which are located in <SMP_HOME>\MobileSDK<version>\HybridApp\API\AppFramework.

Making calls to the Hybrid Web Container is platform-dependent, as shown in this example:

Example 1

        if (isWindowsMobile()) {
            var xmlhttp = getXMLHTTPRequest();
            xmlhttp.open("POST", "/sup.amp?querytype=setscreentitle&version=2.0", false);
            xmlhttp.send("title=" + encodeURIComponent(screenTitle));
        }
        else if (isIOS()) {
            var xmlHttpReq = getXMLHTTPRequest();
            xmlHttpReq.open("GET", "http://localhost/sup.amp?querytype=setscreentitle&version=2.0&title=" + encodeURIComponent(screenTitle), true);
            xmlHttpReq.send("");
        }
        else if (isAndroid()) {
            var request = "http://localhost/sup.amp?querytype=setscreentitle&version=2.0&title=" + encodeURIComponent(screenTitle);
            _WorkflowContainer.getData(request);
        }        
        else { //must be BlackBerry
            var xmlhttp = getXMLHTTPRequest();
            xmlhttp.open("POST", "http://localhost/sup.amp?querytype=setscreentitle&version=2.0", false);
            xmlhttp.send("title=" + encodeURIComponent(screenTitle));
        }
From a high-level perspective, these are the query types used for calling the Hybrid Web Container.

setscreentitle

Sets the native screen title on the Hybrid Web Container.

close

Closes the native Hybrid Web Container (Windows Mobile only).

addMenuItem

Adds a single menu item to the Hybrid Web Container.

removeallmenuitems

Removes all the menu items from the Hybrid Web Container.

clearrequestcache

Clears the entire Online Request cache for the current Hybrid App.

clearrequestcacheitem

Clears a single Online Request cache entry for the current Hybrid App.

logtoworkflow

Logs a message to the AMPHostLog.txt (mocalog.txt for iOS) on the device. You can retrieve this log file remotely from SAP Control Center.

showcertpicker

Shows a native platform certificate picker on the device for selecting certificate credentials.

showInBrowser

On iOS, this function shows the URL in the Hybrid Web Container in a separate browser instance. On all other platforms, this launches the native Web browser in another window with the given URL.

showattachment

Using third party file viewers, this function displays an attachment that has previously been downloaded using the downloadattachment querytype in a separate window.

Note: On iOS, the attachment is shown within the Hybrid Web Container.

showlocalattachment

Using third party file viewers, this function displays an attachment that was included as part of the Hybrid App .zip package, in a separate window.

Note: On iOS, the attachment is shown within the Hybrid Web Container.

rmi

This function executes an online request to the SAP Mobile Server synchronously, in other words, a network connection must be available. This can indicate results should be cached for future access (in which case a network connection does not need to be available).

downloadattachment

Requests an attachment to be downloaded from the SAP Mobile Server through an object query. A network connection is required for this operation. This operation occurs asynchronously, and the calling JavaScript is notified when it is complete.

submit

Submits the current MessageValueCollection to the SAP Mobile Server for processing by the server plug-in. This operation occurs asynchronously. If a network connection is not available when this operation is performed, the request is queued up and executed the next time a network connection is available.

alert

Shows a message box in native code (iOS and Android platforms only).

loadtransformdata

Requests the Hybrid Web Container for the transform data (the contents of the e-mail message) for the current message.

addallmenuitems

Instructs the Hybrid Web Container to add the supplied list of menu items.

formredirect

Notifies the Hybrid Web Container that a screen navigation is occurring, and to update credentials in the credentials cache, if required.