Showing posts with label Binding Context. Show all posts
Showing posts with label Binding Context. Show all posts

Tuesday, September 6, 2016

Invoking Application module method as default activity with return parameter from bean

Sometimes when task flow is initialized before loading page/fragment we need to execute Application Module method which returns parameter to manipulate some logic. 

Shown below is one way to achieve this kind of use case .

  1. Have a method in AMImpl which returns parameter , here Map is returned .
  2. Drag and drop the AM method on task flow , which creates binding in DataBinding.cpx


DataBinding.cpx will have a page map and page definition usages

<page path="/Sample-TF.xml#Sample-TF@employeeAMMethod"                         usageId="view_Sample_TF_Sample_TF_employeeAMMethodPageDef"/>

<page id="view_Sample_TF_Sample_TF_employeeAMMethodPageDef"

   path="view.pageDefs.Sample_TF_Sample_TF_employeeAMMethodPageDef"/>

Now implement a bean method activity on task flow , below i have execute AMImpl method ,result is returned and setting to bean variable which i will be showing as output text in fragment.


            //Get the current binding context
        BindingContext binding = BindingContext.getCurrent();

        //Find our binding container by name (page id in the DataBindings.cpx)
        DCBindingContainer dcBinding =
            binding.findBindingContainer("view_Sample_TF_Sample_TF_employeeAMMethodPageDef");
        //Execute the method
        OperationBinding operation = dcBinding.getOperationBinding("employeeAMMethod");
        operation.execute();





Output on fragment 



Happy Learning !!!