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.

3 comments: