Sunday, September 22, 2013

Passing Parameters to Region using Parameter Map


  • We can pass parameters to region using parameter property of the region.
  • Parameter Map object is of java.util.Map
  • ADF region or ADF dynamic region can use parameter map 
  • Parameter Map reduces number of parameters under bindings in the page def file of the jspx file where we are dropping the task flow as region.
  • If there are same parameters in the binding and the map the map take the precedence 


Create a bounded task flow
Added two input parameters to the bounded task flow test1 and test2. Drag and drop the task flow to the testParamMapToRegion.jspx. Code for the testParamMapToRegion.jspx is as shown below:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="testParamMapToRegion.jspx" id="d1">
            <af:form id="f1">
                <af:region value="#{bindings.parameterMaptoRegion1.regionModel}" id="r1"/>
            </af:form>
        </af:document>
    </f:view>

</jsp:root>

Create a managed bean with pageflowScope in adfc-config.xml 

package view;

import java.util.HashMap;
import java.util.Map;

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

    public Map getMyMap() {
        Map map = new HashMap();
       // Parameter value is set here.
        map.put("test1", "test1");
        map.put("test2", "test2");
        return map;
    }
}

The code for the map_view1.jspx is as shown 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=" Test =#{pageFlowScope.test1}" id="ot1"/>
     <af:outputText value=" Test =#{pageFlowScope.test2}" id="ot2"/>
  </af:panelGroupLayout>

</jsp:root>

Run the testParamMapToRegion.jspx page and see the pageFlowScope parameters test1 and test2.

Saturday, September 14, 2013

Page Fragment and View Port


  • Page fragments .jsff renders content in another jsf page 
  • Page fragment should not have more than one root element 
  • Page Fragment should not have af:document,f:view,f:form,head,body elements 
  • Bounded task flow add to jsf page as region should have page fragments only 


<?xml version='1.0' encoding='UTF-8'?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"></jsp:root>

  • View port is the display area capable of navigating independently of other view ports ,region or browser window 
  • We can set security on bounded task flow displayed over region 

ADF Region with parameter

We can execute a bounded task flow with page or jsff fragment using ADF region.ADF region helps in re-usability of the code.ADF region consists of a af:region and the instance object is of oracle.adf.view.rich.model.RegionModel .On first rendering the ADF region content is the first view activity in the bounded task flow.taskflow in the page binding identifies the bounded task flow uses region.mulitaskFlow identifies list of bounded task flow uses region.We can pass values to region using input parameters or using contextual events .parameterMap is an object of java.util.Map identifies what input parameters the task flow passes from task flow to region.Dynamic region is the region what bounded task flow to render on runtime.

Create a bounded task flow with input parameter
region_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="Input = #{pageFlowScope.inputParameter1}" id="ot1"/>
  </af:panelGroupLayout>

</jsp:root>

Drag and drop the bounded task flow as region 

Edit the page definition of the test page and pass the parameter either through value or EL expression.
Page definition file of the test page.

<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="12.1.2.66.68" id="testRegionPageDef"
                Package="view.pageDefs">
  <parameters/>
  <executables>
    <variableIterator id="variables"/>
    <taskFlow id="btfadfregion1" taskFlowId="/WEB-INF/btf-adf-region.xml#btf-adf-region" activation="deferred"
              xmlns="http://xmlns.oracle.com/adf/controller/binding">
      <parameters>
        <parameter id="inputParameter1" value="Testing"/>
      </parameters>
    </taskFlow>
  </executables>
  <bindings/>
</pageDefinition>

The code for region_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="Input = #{pageFlowScope.inputParameter1}" id="ot1"/>
  </af:panelGroupLayout>
</jsp:root>


Run the page and see the input parameter from the region_view1.jsff 

Saturday, September 7, 2013

Return Value For Bounded Task Flow

Bounded task flow can return a value.Task Flow call activity return value by reference.
Create a task flow that is called as below :

Also see the return value specified

Outcome of the task flow return activity is taskFlowReturn1.
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:button text="button 1" id="b1" action="toView2"/>
  </af:panelGroupLayout>

</jsp:root>
Calling Task Flow is as below 


See the return value specified coming over to the task flow call activity.
return_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:button text="button 1" id="b1" action="toTFCall"/>
  </af:panelGroupLayout>
</jsp:root>
return_calling_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.retVal1}" id="ot1"/>
</jsp:root>
Click on button and finally see the "Hello World" printed.

Code snippet for the calling task flow 
<task-flow-call id="return_called_tf">
      <task-flow-reference>
        <document>/WEB-INF/return_called_tf.xml</document>
        <id>return_called_tf</id>
      </task-flow-reference>
      <return-value id="__1">
        <name>returnValue1</name>
        <value>#{pageFlowScope.retVal1}</value>
      </return-value>
    </task-flow-call>

Code snippet for the called task flow 

  <task-flow-definition id="return_called_tf">
    <default-activity>return_called_view1</default-activity>
    <return-value-definition id="__1">
      <name>returnValue1</name>
      <value>Hello World</value>
      <class>java.lang.String</class>
    </return-value-definition>

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.