Search This Blog

Wednesday, 29 May 2013

ADF Code Unit: For Calling AM Method

1) Expose the method from AM
2) Create a binding in page definition.
3) Use the below code.

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;

    public String cb1_action() {
        // Add event code here...
        System.out.println("In CBAction");
        BindingContainer bindingContainer = BindingContext.getCurrent().getCurrentBindingsEntry();
        DCBindingContainer bc = (DCBindingContainer)bindingContainer;
        OperationBinding operationBinding = bc.getOperationBinding("testMthd");  
        if(operationBinding != null){
            System.out.println("In IF");
            operationBinding.execute();
        }
        System.out.println("goinf out of CB Action.");
        
        return null;
    }

Wednesday, 15 May 2013

Calling Javascript method using java in ADF


Calling Javascript method using java in ADF

While working in my project I came to a situation in which I have to make a call to a JavaScript method, on load of the page. The JavaScript method was taking a parameter as an input and the value of the parameter has to come from java class.

Let's find the solution in the below example : 

1.  Create a sample jsff page and write a JavaScript method inside it. E.g "homeLoad.jsff" containing a JavaScript method as "myMethod(args)"




2. Create a Class and Java method such as "onLoadOfPage()", which will contain the code to call a JavaScript method and passing a parameter.



3. Create a taskflow such as "myTF.xml" and use Java method as default activity and jsff as an outcome.



4. Now, finally create a jspx page as "Home.jspx" and use taskflow as a region. Run the page.

Output :