Here some pics of the example I made. In the mainpage I have two buttons with these buttons I pass a event to the region so it goes to the next pagefragment. When this happens the regionNavigationListener is fired and the new displayed view is passed on the mainpage so I can disable the right button.
The bounded Task Flow I use for this example with two pages and some control flow cases between these two fragments
Here is the mainpage jsf page code with the regionNavigationListener on the af:region component.
<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=windows-1252"/>
<f:view>
<af:document>
<af:form>
<af:panelHeader text="Main page">
<f:facet name="context">
<af:panelGroupLayout layout="horizontal">
<af:outputLabel value="Old view"/>
<af:outputText value="#{Main.oldRegionView}"
id="old"/>
<af:spacer width="50" height="1"/>
<af:outputLabel value="New view"/>
<af:outputText value="#{Main.newRegionView}"
id="new"/>
</af:panelGroupLayout>
</f:facet>
<f:facet name="legend">
<af:toolbar>
<af:commandToolbarButton text="Page1"
id="buttonPage1"
actionListener="#{Main.pageOneActionListener}"
disabled="#{Main.newRegionView eq '/region-task-flow/page1'}"/>
<af:commandToolbarButton text="Page2"
id="buttonPage2"
actionListener="#{Main.pageTwoActionListener}"
disabled="#{Main.newRegionView eq '/region-task-flow/page2'}"/>
</af:toolbar>
</f:facet>
<af:panelBox text="Task Flow Region" showDisclosure="false">
<f:facet name="toolbar"/>
<af:region value="#{bindings.regiontaskflow1.regionModel}"
id="regio1"
binding="#{Main.region}"
regionNavigationListener="#{Main.navigationListener}"/>
</af:panelBox>
</af:panelHeader>
</af:form>
</af:document>
</f:view>
</jsp:root>
and here is backing bean code where I pass a queueActionEventInRegion event so it navigates to the other page fragment.
package nl.whitehorses.tf.region.view.backing;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseId;
import oracle.adf.view.rich.component.rich.fragment.RichRegion;
import oracle.adf.view.rich.context.AdfFacesContext;
import oracle.adf.view.rich.event.RegionNavigationEvent;
public class MainPage {
private RichRegion region;
private String OldRegionView;
private String NewRegionView;
private String outcome;
public MainPage() {
}
public void pageOneActionListener(ActionEvent actionEvent) {
outcome = "to1";
region.queueActionEventInRegion(getMethodExpression("#{Main.getOutcomeExpression}"),
null, null, false, -1, -1,
PhaseId.ANY_PHASE);
}
public void pageTwoActionListener(ActionEvent actionEvent) {
outcome = "to2";
region.queueActionEventInRegion(getMethodExpression("#{Main.getOutcomeExpression}"),
null, null, false, -1, -1,
PhaseId.ANY_PHASE);
}
private MethodExpression getMethodExpression(String name) {
FacesContext facesCtx = FacesContext.getCurrentInstance();
Application app = facesCtx.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesCtx.getELContext();
return elFactory.createMethodExpression(elContext, name, String.class, new Class[] { });
}
public String getOutcomeExpression() {
return outcome;
}
public void navigationListener(RegionNavigationEvent event) {
NewRegionView = event.getNewViewId();
OldRegionView = event.getOldViewId();
AdfFacesContext.getCurrentInstance().addPartialTarget(getUIComponent("old"));
AdfFacesContext.getCurrentInstance().addPartialTarget(getUIComponent("new"));
AdfFacesContext.getCurrentInstance().addPartialTarget(getUIComponent("buttonPage1"));
AdfFacesContext.getCurrentInstance().addPartialTarget(getUIComponent("buttonPage2"));
}
private UIComponent getUIComponent(String name) {
FacesContext facesCtx = FacesContext.getCurrentInstance();
return facesCtx.getViewRoot().findComponent(name);
}
public void setRegion(RichRegion region) {
this.region = region;
}
public RichRegion getRegion() {
return region;
}
public String getOldRegionView() {
return OldRegionView;
}
public String getNewRegionView() {
return NewRegionView;
}
}
Here is the example workspace.