Search code examples
oracle-adforacle-adf-mobile

ADF Mobile: Invoke AMX Page to display on user screen using JavaScript


My question is very simple.

In ADF Mobile, I have HTML page and there is a button on it. I want to run JavaScript code on button click and navigate to AMX Page. How I can achieve this functionality.

Thank You!


Solution

  • In button properties in AMX page click action listener and create Bean and Method

    Add below code in order to execute zoomIn JS Function

    AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.mohamed.ios.feature1",
                                                                 "zoomIn",
                                                                  new Object[] { });
    
    • First Parameter: Feature Id
    • Second Parameter: Javascript Function
    • Name Third Parameter: Java Script Function Parameters

    If it's HTML page once you choose a button in property inspector under javascript you will find all the javascript events you can use( if property inspector not visible click View -> Property Inspector).

    you can add the JS function in the OnClick event then in that JS function you can use below code to go to the feature that has your AMX page.

    adf.mf.api.gotoFeature("feature0",
              function(req, res) { alert("gotoFeature complete"); },
    function(req, res) { alert("gotoFeature failed with " +
                                adf.mf.util.stringify(res); }
       );
    

    Make sure you include the JS file in feature under content tab.

    And in order to navigate to AMX page from a button on another AMX page pass the flowCase to below method

    public void doNavigation(String flowCase) {
    
        AdfmfContainerUtilities.invokeContainerJavaScriptFunction(AdfmfJavaUtilities.getFeatureName(),
                                                                  "adf.mf.api.amx.doNavigation",
                                                                  new Object[] { flowCase });
    }
    

    The doNavigation method is calling a standard ADFM JS API called adf.mf.api.amx.doNavigation and it passes the flowCase name to it.