The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

How-to programmatically display a popup message

Frank Nimphius
Master Principal Product Manager

For an ADF mobile sample I needed to display a confirmation message upon successful upload of an image. Because I could not see how to do this from Java using the ADF Mobile popup dialog, I used JavaScript. The JavaScript function I called is part of PhoneGap, which is neat because this ensures I don't have to maintain custom JavaSCript code in my AMX page.  To call the PhoneGap notification dialog, I  added

20-October 2013: important. Since I've written this sample, the libraries have been changed from PhoneGap to Cordova. Make sure the script below is changed to the Cordova JS (!!!)

Script sample

to the AMX page. I added this script tag to the body section of  the amx:panelPage component tag. Note that the relative addressing /../.../.../ in the JS reference is for AMX pages that are in the public_html folder. If your page is in a sub folder, you will need to add an extra "/.." for each folder

In my Java bean, which I called from a method binding, I used the ADF Mobile AdfmfContainerUtilities.invokeContainerJavaScriptFunction(...) call to invoke the PhoneGap "navigator.notification.alert" function

navigator.notification.alert(message, alertCallback, [title], [buttonName])

See: http://docs.phonegap.com/en/1.0.0/phonegap_notification_notification.md.html

The Java call is shown below:

            new Object[] {"Image uploaded: \n " +
           "File Name: "+fileName+"\n File Type: "+fileType,"",
            "Image Uploaded to Server", "Ok"});

Note the use of the object array to pass multiple arguments to the JavaScript function. The "adf.sample.mobile.PhotoUpload" string is the ADF Mobile feature Id of the feature that contains the AMX page with the JavaScript reference.

The result is shown in the image below:

PhoneGap dialog displayed in ADF Mobile

Using the same technique you can call any other PhoneGap JavaScript function from ADF Mobile (and your custom JavaScripts as well)
See also:


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.