Sunday, September 29, 2013

ADF Page to render Unknown Number of Regions


Create two task flows

Task Flow 1:


dyregion_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="Region 1" id="ot1"/>
  </af:panelGroupLayout>

</jsp:root>

Task Flow 2:
dynamicRegion_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="Region 2" id="ot1"/>
  </af:panelGroupLayout>

</jsp:root>

Create the managed bean in the pageFlowScope. The code for the managed bean is as below
package view;

import java.util.ArrayList;
import java.util.List;

import oracle.adf.controller.TaskFlowId;
import oracle.adf.controller.binding.TaskFlowBindingAttributes;

public class MultiBean {
  
   private List<TaskFlowBindingAttributes> mattrs= new ArrayList<TaskFlowBindingAttributes>(5);
   public MultiBean() {
      
       TaskFlowBindingAttributes tfAttr= new TaskFlowBindingAttributes();
       tfAttr.setId("region1");
       tfAttr.setTaskFlowId(new TaskFlowId("/WEB-INF/tfDynamicRegion.xml","tfDynamicRegion"));
       mattrs.add(tfAttr);
      
       tfAttr= new TaskFlowBindingAttributes();
       tfAttr.setId("region2");
       tfAttr.setTaskFlowId(new TaskFlowId("/WEB-INF/tfDyanamicRegion1.xml","tfDyanamicRegion1"));
       mattrs.add(tfAttr);
   }
   public List<TaskFlowBindingAttributes> getTaskFlowList() {
       return mattrs;
   }
  

}

Create a test page and go to the pageDef of the page. Add Executables as below

Click on OK to go the screen below and enter the values as shown.

Create the test page
testMultiFlow.jspx
<?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="testMultiFlow.jspx" id="d1">
            <af:form id="f1">
                <af:panelGroupLayout id="pgl1">
             
                    <af:panelTabbed id="pt1">
                    <af:forEach items="#{bindings.multiId.taskFlowBindingList}" var="regs">
                   
                        <af:showDetailItem text="#{regs.name}" id="sdi1">
                                <af:panelBox text="#{regs.name}" id="pb2">
                                    <f:facet name="toolbar">
                                     <af:region value="#{regs.regionModel}" id="r2"/>
                                    </f:facet>
                                </af:panelBox>
                            </af:showDetailItem>
                        </af:forEach>
                    </af:panelTabbed>
                </af:panelGroupLayout>
            </af:form>
        </af:document>
    </f:view>

</jsp:root>

Run and see the two region displayed in the showdetailItems of the Tabed layout.

No comments:

Post a Comment