Thursday, August 29, 2013

ADF Task Flow Call Activities

Task Flow call activities are getting used to call a bounded task flow from either bounded task flow or from unbounded task flow.Chaining of class flow  is possible means one task flow can another and that one can call another etc.Bounded task flow can accept input parameters. Calling task flow can pass the parameters to the called task flow. When we drag and drop a bounded task flow to the task flow bounded or unbounded the input parameters of the called task flow will be available in the calling task flow to pass the values.Return parameters for task flow is also possible.

We can add task flow call by following method

  •  Drag and drop a bounded task flow to either bounded or unbounded task flow
  •  Drag a task flow call activity to the task flow and browse to the appropriate bounded task flow

Called task flow :
Create a bounded called task flow as below
See below the input parameter defined for the called task flow 
Code for called_view1.jspx 
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <af:panelGroupLayout id="pgl1">
    <af:outputText value="Called  #{pageFlowScope.inputParameter1}" id="ot1"/>
  </af:panelGroupLayout>
</jsp:root>


Calling Task flow
Create a bounded task flow to call the other task flow.
Create the method call of the above task flow as shown below
Method here refers to a managed bean method in pageFlowScope. Also note the default outcome defined.
The managed bean in pageFlowScope defined is as below
package test.view;

import oracle.adf.view.rich.context.AdfFacesContext;

public class TestBTCall {
    private String testVal;

    public void setTestVal(String testVal) {
        this.testVal = testVal;
    }

    public String getTestVal() {
        return testVal;
    }

    public TestBTCall() {
        super();
    }
    public void setVariable() {
      //  HttpServletRequest req=(HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
      
        
       AdfFacesContext.getCurrentInstance().getPageFlowScope().put("testValue", "Testing");
        System.out.println(AdfFacesContext.getCurrentInstance().getPageFlowScope().get("testValue"));
    }

}

Here the bean set the pageFlowScope variable "testValue".Code for calling_view1.jspx is as below 
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <af:panelGroupLayout id="pgl1">
    <af:outputText value="Calling_view1" id="ot1"/>
    <af:button text="button 1" id="b1" action="toTFCall"/>
  </af:panelGroupLayout>
</jsp:root>

Task flow call activities details are as shown 

The input parameters are getting from the called task flow by default.Note here the task flow reference is static.
Running the task flow:
Drag and drop the calling task flow to a region of a test.jspx page. Run the jspx file. Click on the button in calling_view1.jspx. See the output "Called Testing" displayed.

Code snippet for task flow calling :

<task-flow-call id="taskFlowCalled">
      <task-flow-reference>
        <document>/taskFlowCalled.xml</document>
        <id>taskFlowCalled</id>
      </task-flow-reference>
      <input-parameter id="__3">
        <name>inputParameter1</name>
        <value>#{pageFlowScope.testValue}</value>
      </input-parameter>
    </task-flow-call>

No comments:

Post a Comment