Saturday, September 14, 2013

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 

2 comments:

  1. Damit das funktioniert, muss aber in der task-flow.xml der Parameter in der "input-parameter-definition" definiert werden!
    Zum Beispiel so;


    inputParameter1
    #{pageFlowScope.inputParameter1}



    Anders funktioniert es doch gar nicht, oder? Bei mir jedenfalls nicht.

    ReplyDelete
  2. <input-parameter-definition id="__3">
    <name>commonEntityType</name>
    <value>#{pageFlowScope.commonEntityType}</value>
    <required/>
    </input-parameter-definition>

    ReplyDelete