Saturday, September 7, 2013

Sharing Data Control between Task Flows

A container associated with task flow that contains the data control is called Data control frame. Data control frame is created for each task flow that's entered results in each task flow having it's own unique instance of data control issues .Data control scope is shared or isolated.Shared mean the DataControlFrame is of calling and isolated is having it's own DataControlFrame.Shared wont work if the calling task flow uses URL to invoke called task flow.


<task-flow-definition id="shared_dc_calling">
    <default-activity>shared_dc_view1</default-activity>
    <data-control-scope>
      <shared/>

    </data-control-scope>
......................

If the task flow is in transaction data-control-option effects transaction options.

Transaction  option
Isolated
shared
requires-existing-transaction
Invalid
-          No transaction exception
-          Existing transaction never committed
requires-transaction
Always Begin new transaction
Begin new transaction if one is not already open
new-transaction
Always begin new transaction
Begin new if  one is not open and throw exception if already one there
<default> none
New data control frame is created without an open transaction
Task Flow  uses the calling task flow's transaction for shared data control for any new data controls it creates.task flow does not create or requires a transaction


Monday, September 2, 2013

Passing Parameter to a Bounded Task Flow

Parameters can be defined at the task flow call activity or on the the called task flow.
Create a called bounded task flow with parameters as below
inputParam1 can be defined for the task flow as above.Code for param_called_view1,jsff 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="param called view1= #{pageFlowScope.param1}" id="ot1"/>
  </af:panelGroupLayout>

</jsp:root>

Create a calling task flow as shown.
Create an input text field in param_calling_view1.jsff which will be passing to the called bounded task flow through the input parameters .Code for param_calling_view1.jsff :
<?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:inputText label="Label 1" id="it1" value="#{pageFlowScope.inputValue}"/>
  </af:panelGroupLayout>
  <af:button text="Submit" id="b1" action="toCalled"/>
</jsp:root>

Drag and drop the calling task flow to a page as a region and run the page. Provide some value to input text component and submit. The value will be passed to the called task flow through input parameters . Note the task flow code snippet for calling and called task flows 

Calling Task Flow :
<task-flow-call id="ParamCalledTF">
      <task-flow-reference>
        <document>/WEB-INF/ParamCalledTF.xml</document>
        <id>ParamCalledTF</id>
      </task-flow-reference>
      <input-parameter id="__6">
        <name>inputParameter1</name>
        <value>#{pageFlowScope.inputValue}</value>
      </input-parameter>
    </task-flow-call>

Called Task flow :

<task-flow-definition id="ParamCalledTF">
    <default-activity>param_called_view1</default-activity>
    <input-parameter-definition id="__2">
      <name>inputParameter1</name>
      <value>#{pageFlowScope.param1}</value>
      <class>java.lang.String</class>
    </input-parameter-definition>
    <view id="param_called_view1">
      <page>/param_called_view1.jsff</page>
    </view>
    <use-page-fragments/>
  </task-flow-definition>


Passing Parameter to ADF view activities

Parameters can be passed to a view activity in task flow.Create a bounded task flow as below
Look at the page parameters section on properties of viewParam_view2.jsff.Each parameter has a from value and to value.
Code for viewParam_view1.jsff :
<?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"
          xmlns:f="http://java.sun.com/jsf/core">
  <af:panelGroupLayout id="pgl1">
    <af:button text="button 1" id="b1" action="toParam2">
      <f:setPropertyActionListener target="#{pageFlowScope.empID}" value="2345"/>
    </af:button>
  </af:panelGroupLayout>

</jsp:root>

empId is set from this page using an property listener action listener.

Code for viewParam_view2.jsff 
<?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="Test=#{pageFlowScope.empNo}" id="ot1"/>
  </af:panelGroupLayout>
</jsp:root>
Drag and drop the task flow as a region in a page and run the page.Click on the button to set the property and that can be viewed in the view2.



Saturday, August 31, 2013

ADF task Flow Activities with Page Def file

Page definition files define the binding objects that populate data at runtime .This file bind the UI component with the data control .Following are the task flow activities use page definition file to bind data control

  • Method call
  • Router
  • Task Flow call 
  • View 

How to create Page def file?
Right click on each activity and select the option "Create Page Definition".Sample page def file for a task flow call activity
<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="12.1.2.66.68"
                id="tfListeners_tfListeners_tfListenerCalledPageDef" Package="view.pageDefs" SkipValidation="true">
  <parameters/>
  <executables>
    <variableIterator id="variables"/>

  </executables>

ADF Task Flow Return Activity

Return Activity is used when bounded task flow completes and send control flow back to caller.Return activity works only with the bounded task flow.Return task flow's reentry is option is set only if the task flow's reentry-outcome-dependent is set.End transaction option is available for the Return activity for transaction commit and rollback.Also we can set the restore save point option to either true or false.

Create a called task flow as below

return_called_view1.jsff
<?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="Return Activity Calling TF" id="ot1"/>
    <af:button text="button 1" id="b1" action="testOutCome"/>
  </af:panelGroupLayout>

</jsp:root>

return_called_view1.jsff :
<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 Task Flow" id="ot1"/>
    <af:button text="Calling Retun" id="b1" action="toReturn"/>
  </af:panelGroupLayout>
</jsp:root>

Task flow return activity options are as shown below 
The outcome "goToView2" is the control flow case defined in the calling task flow. Also look at the other options like Reentry,End Transaction and Restore Save Point.

Calling Task flow:
Also set the listeners for the task flow call activity. Below the managed bean for the before and after listener for the task flow call activity.

package test.view;


public class TFCallActivityListeners {
    public TFCallActivityListeners() {
        super();
    }

    public void beforeListerner() {
        System.out.println("Before listener called ");

    }

    public void afterListener() {
        System.out.println("After listener called ");
    }
}

The code for the jspx files in the calling task flow
return_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="Return activity" id="ot1"/>
    <af:button text="button 1" id="b1" action="tocall"/>
  </af:panelGroupLayout>
</jsp:root>

return_view2.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="To view2" id="ot1"/>
  </af:panelGroupLayout>
</jsp:root>

Drag and drop the calling task flow to a jspx file as a region and run the page. Click through the command buttons to reach the final view in the UI.Check the jdeveloper log to see the after listeners are executed.

ADF Task FLow Call Activity Listeners

Task flow call activity can before and after listeners.These listeners identify the start and end of the bounded task flow.The listener method cannot take parameters.Control flow must return from bounded task flow using control flow rule to execute the after listener.User leaves bounded task flow using browser back button or entering to other URL the after listener won't be called.Need to use task flow finalizers to release resources in this case.
Create a called task flow with task flow return activity
listener_called_view1.jsff:
<?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 Listener" id="ot1"/>
    <af:button text="Return" id="b1" action="toReturn"/>
  </af:panelGroupLayout>

</jsp:root>

Create a calling Task flow 
listener_view1.jsff 

<?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="TF Listeners" id="ot1"/>
    <af:button text="button 1" id="b1" action="toCall"/>
  </af:panelGroupLayout>
</jsp:root>

Create a managed bean in request scope as below 
package test.view;


public class TFCallActivityListeners {
    public TFCallActivityListeners() {
        super();
    }

    public void beforeListerner() {
        System.out.println("Before listener called ");

    }

    public void afterListener() {
        System.out.println("After listener called ");
    }
}
Drag and drop the calling task flow to the jspx page as a region and run the page. Click on the buttons in the views.Note the listeners are executed and see the messages in the log.

Thursday, August 29, 2013

URL Syntax to Invoke Bounded Task Flow

Sample URL is as below :

Format is 
<server-root>/<app-context>/faces/adf.task-flow?adf.tfId=<task flow definition id>&adf.tfDoc=<document name>&<named parameter>=<named parameter value>
Parameter name should not begin with an underscore ('_') .This is reserved for internal purpose.