Thursday, March 24, 2011

Region Interaction Example 4 - Using Parent Action Component

Assume the following UI:


Here, the top region before the separator represents the parent task flow, and the region below the separator represents the child task flow. In the child task flow, on clicking the ‘Move Parent’ button, the parent task flow navigation is performed, as shown below:



However, on clicking the ‘Move Child’ button, the navigation in the child task flow is performed, as shown in below image:



To perform this type of navigation, Parent Action component is used. Parent action component is used in the child task flow to perform the navigation in the parent task flow. The following image shows the parent task flow used in the above specified flow:


The ParentView.jsff refers to the child task flow and the following image shows the content of the child task flow:


The files used in this flow are:


Here is the code of the above specified file used in the flow:
MasterPage.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:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:form id="f1">
        <af:region value="#{bindings.ParentTaskFlow1.regionModel}" id="r1"/>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>
ParentTaskFlow.xml
<?xml version="1.0" encoding="windows-1252" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
  <task-flow-definition id="ParentTaskFlow">
    <default-activity id="__1">ParentView.jsff</default-activity>
    <view id="ParentView.jsff">
      <page>/ParentView.jsff</page>
    </view>
    <view id="ParentView2.jsff">
      <page>/ParentView2.jsff</page>
    </view>
    <control-flow-rule id="__2">
      <from-activity-id id="__3">ParentView.jsff</from-activity-id>
      <control-flow-case id="__5">
        <from-outcome id="__6">move</from-outcome>
        <to-activity-id id="__4">ParentView2.jsff</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule id="__7">
      <from-activity-id id="__8">ParentView2.jsff</from-activity-id>
      <control-flow-case id="__10">
        <from-outcome id="__11">back</from-outcome>
        <to-activity-id id="__9">ParentView.jsff</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <use-page-fragments/>
  </task-flow-definition>
</adfc-config>
ParentView.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">
  <p>
    <af:outputText value="First View In Parent Task Flow" id="ot1"/>
    <af:commandButton text="Move" id="cb1" action="move"/>
  </p>
  <af:separator id="s1"/>
  <af:region value="#{bindings.ChildTaskFlow1.regionModel}" id="r1"/></jsp:root>
ParentView.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:outputText value="Second View In Parent Task Flow" id="ot1"/>
  <af:commandButton text="Back" id="cb1" action="back"/>
</jsp:root>
ChildTaskFlow.xml
<?xml version="1.0" encoding="windows-1252" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
  <task-flow-definition id="ChildTaskFlow">
    <default-activity id="__1">ChildRegion1.jsff</default-activity>
    <managed-bean id="__37">
      <managed-bean-name id="__35">ChildRegion1Bean</managed-bean-name>
      <managed-bean-class id="__36">ChildRegion1Bean</managed-bean-class>
      <managed-bean-scope id="__38">request</managed-bean-scope>
    </managed-bean>
    <view id="ChildRegion1.jsff">
      <page>/ChildRegion1.jsff</page>
    </view>
    <view id="ChildRegion2.jsff">
      <page>/ChildRegion2.jsff</page>
    </view>
    <parent-action id="parentAction1">
      <parent-outcome>move</parent-outcome>
      <outcome id="__24">next</outcome>
    </parent-action>
    <parent-action id="parentAction2">
      <parent-outcome>move1</parent-outcome>
      <outcome id="__33">next</outcome>
    </parent-action>
    <control-flow-rule id="__2">
      <from-activity-id id="__3">ChildRegion2.jsff</from-activity-id>
      <control-flow-case id="__4">
        <from-outcome id="__6">back</from-outcome>
        <to-activity-id id="__5">ChildRegion1.jsff</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule id="__12">
      <from-activity-id id="__13">ChildRegion1.jsff</from-activity-id>
      <control-flow-case id="__18">
        <from-outcome id="__25">move1</from-outcome>
        <to-activity-id id="__17">parentAction1</to-activity-id>
      </control-flow-case>
      <control-flow-case id="__26">
        <from-outcome id="__28">move2</from-outcome>
        <to-activity-id id="__27">parentAction2</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule id="__19">
      <from-activity-id id="__20">parentAction1</from-activity-id>
      <control-flow-case id="__22">
        <from-outcome id="__23">next</from-outcome>
        <to-activity-id id="__21">ChildRegion2.jsff</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule id="__29">
      <from-activity-id id="__30">parentAction2</from-activity-id>
      <control-flow-case id="__31">
        <from-outcome id="__34">next</from-outcome>
        <to-activity-id id="__32">ChildRegion2.jsff</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <use-page-fragments/>
  </task-flow-definition>
</adfc-config>
ChildRegion1.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:outputText value="First Region Of The Child Task Flow" id="ot1"/>
  <af:commandButton text="Move Parent" id="cb1" action="move1"/>
  <af:commandButton text="Move Child" id="cb2" action="move2"/>
</jsp:root>


ChildRegion2.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:outputText value="Second Region Of The Child Task Flow" id="ot1"/>
  <af:commandButton text="Back" id="cb1" action="back"/>
</jsp:root>

That's it.

JDev Release 11.1.1.4

No comments:

Post a Comment