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 that the Mobile Workflow Forms editor generates.

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 Web Container.

close

Closes the native Web Container (Windows Mobile only).

addMenuItem

Adds a single menu item to the Web Container.

removeallmenuitems

Removes all the menu items from the Web Container.

clearrequestcache

Clears the entire Online Request cache for the current Mobile Workflow application.

clearrequestcacheitem

Clears a single Online Request cache entry for the current Mobile Workflow application.

logtoworkflow

Logs a message to the AMPHostLog.txt (mocalog.txt for iOS) on the device. This log file can be retrieved remotely from Sybase 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 Workflow 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 Web Container.

showlocalattachment

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

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

rmi

This function executes an online request to the Unwired 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 Unwired 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 Unwired 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 Web Container for the transform data (the contents of the e-mail message) for the current Workflow message.

addallmenuitems

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

formredirect

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