For this blogpost I made an Example with one JSPX page and this page contains two Regions. The first is the Top TF and the second is a dynamic Region with Center 1 & 2 TF. Start is part of the JSPX page and can call the Center 1 & 2 methods directly in the dynamic region bean.
For showing the Center Task Flows from the Top Task Flow you can use the Parent Action activity.
Here is the code of the main JSPX page with in the start facet ,the two buttons which can call the backingbean methods.
<?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 id="d1" title="Example"> <af:form id="f1"> <af:panelStretchLayout id="psl1" startWidth="239px" topHeight="95px"> <f:facet name="center"> <af:region value="#{bindings.dynamicRegion1.regionModel}" id="centerRegion"/> </f:facet> <f:facet name="start"> <af:panelHeader text="Start" id="ph1" inlineStyle="width:239px; height:423px;"> <f:facet name="toolbar"> <af:toolbar id="t1"> <af:commandToolbarButton text="Center1" id="ctb1" action="#{backingBeanScope.MainRegionHandler.showCenter1TF}"/> <af:commandToolbarButton text="Center2" id="ctb2" action="#{backingBeanScope.MainRegionHandler.showCenter2TF}"/> </af:toolbar> </f:facet> </af:panelHeader> </f:facet> <f:facet name="top"> <af:region value="#{bindings.top1.regionModel}" id="centerTop"/> </f:facet> </af:panelStretchLayout> </af:form> </af:document> </f:view> </jsp:root>The dynamic region bean with the showCenter1TF and showCenter2TF methods.
package nl.whitehorses.adf.tf.view.beans; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import oracle.adf.controller.TaskFlowId; import oracle.adf.view.rich.context.AdfFacesContext; public class MainRegionHandler { private String taskFlowIdCenter1 = "/WEB-INF/center1.xml#center1"; private String taskFlowIdCenter2 = "/WEB-INF/center2.xml#center2"; private String taskFlowId = taskFlowIdCenter1; public MainRegionHandler() { } public TaskFlowId getDynamicTaskFlowId() { return TaskFlowId.parse(taskFlowId); } public String showCenter1TF() { taskFlowId = taskFlowIdCenter1; AdfFacesContext.getCurrentInstance().addPartialTarget(getUIComponent("centerRegion")); return null; } public String showCenter2TF() { taskFlowId = taskFlowIdCenter2; AdfFacesContext.getCurrentInstance().addPartialTarget(getUIComponent("centerRegion")); return null; } private UIComponent getUIComponent(String name) { FacesContext facesCtx = FacesContext.getCurrentInstance(); return facesCtx.getViewRoot().findComponent(name); } }From the Start facet on the main page it is easy to show the right Center Task Flow. From the Top Task Flow you need to do more. First you need to change the parent Task Flow. ( this works in a bounded or unbounded Task Flow ). Add two Method Call activities and a Wildcard Control Flow Rule.
You will later call the goCenter1 and goCenter2 Control Flow cases from the Top Task Flow. This will activate the method call which call the right method in the dynamic region bean. After a successful invocation, it will use the return Control Flow case to return to the page.
The property window of the showCenter1TF Method Call activity looks like this. Here you need to provide the Method value and provide the Fixed Outcome.
Next step is to change the Top Task Flow where you also need to add a Wildcard Control Flow Rule together with two Parent Action activities.
The Parent Action property window looks like this. Here you need to provide the Parent Outcome , this must match with the Control Flow Case of the parent Task Flow and here is the Outcome also return.
And at last the Top fragment with the two buttons which calls the right Control Flow Case.
<?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:panelHeader text="Top TF" id="ph1" inlineStyle="width:995px; height:84px;"> <f:facet name="toolbar"> <af:toolbar id="t1"> <af:commandToolbarButton text="Center1" id="ctb1" action="showCenter1TF"/> <af:commandToolbarButton text="Center2" id="ctb2" action="showCenter2TF"/> </af:toolbar> </f:facet> </af:panelHeader> </jsp:root>That's all and here is the example workspace.