Sunday, 17 August 2014

Calling Java Script function from java bean class in MAF


Sometimes you may get requirement to call javascript function from bean class, Use below invokeContainerJavaScriptFunction() to call the Javascript function.

doAlert() is JS function with one argument.

                AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.ihcmMobile.Absence", "doAlert",
                                                                          new Object[] { " Absence Record Already Exist " });

JS Function:

doAlert = function () {
        var args = arguments;
        var str = ""+ args[0];
        alert(str);  //Absence Record Already Exist  gets printed


1 comment:

  1. Hi,
    I want to open a remote url in maf application for that i have passed url from java to javascript.
    Code in JS:
    var url=arguments[0];, { openExternal:true } );

    Its working fine in android but in iOS its not working.
    So, can you help in this. I have also added url in whitelist for iOS.