<?xml version="1.0" encoding="US-ASCII" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
  <task-flow-definition id="example-flow">
  
    <!--  The default activity is the flow's starting point.  This is where   -->
    <!--  navigation begins when the flow is entered.                         -->
    <default-activity>router</default-activity>
    
    <!-- This flow accepts one input parameter of type String.  The pramater  -->
    <!-- identifies a record to be edited if the record already exists.       -->
    <input-parameter-definition>
      <name>recordKey</name>
      <value>#{pageFlowScope.recordKey}</value>
      <class>java.lang.String</class>
    </input-parameter-definition>
    
    <!-- The following bean definition is local to this flow.                 -->
    <managed-bean>
      <managed-bean-name>recordBean</managed-bean-name>
      <managed-bean-class>example.RecordBean</managed-bean-class>
      <managed-bean-scope>pageFlow</managed-bean-scope>
    </managed-bean>
    
    <!-- This router tests to see if a record key was passed in as an input     -->
    <!-- parameter.  If one was not supplied it generates outcome 'goto-create' -->
    <!-- otherwise it generates outcome 'goto-edit'.                            -->
    <router id="router">
      <case>
        <expression>#{pageFlowScope.recordKey == null}</expression>
        <outcome>goto-create</outcome>
      </case>
      <default-outcome>goto-edit</default-outcome>
    </router>
    
    <!-- This method-call calls a method on a locval managed bean to create a record. -->
    <method-call id="create-record">
      <method>#{pageFlowScope.recordBean.createRecord}</method>
      <outcome>
        <fixed-outcome>goto-edit</fixed-outcome>
      </outcome>
    </method-call>
    
    <!-- This is the edit view where a user edits a record.  -->
    <view id="edit-record">
      <page>/edit-record.jsf</page>
    </view>
    
    <!-- This is the end of the flow.  Control is passed back to the callign flow  -->
    <!-- with outcome 'done'.                                                      -->
    <task-flow-return id="done">
      <outcome>
        <name>done</name>
      </outcome>
    </task-flow-return>

    <control-flow-rule>
      <from-activity-id>router</from-activity-id>
      <control-flow-case>
        <from-outcome>goto-create</from-outcome>
        <to-activity-id>create-record</to-activity-id>
      </control-flow-case>
      <control-flow-case>
        <from-outcome>goto-edit</from-outcome>
        <to-activity-id>edit-record</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule>
      <from-activity-id>create-record</from-activity-id>
      <control-flow-case>
        <from-outcome>goto-edit</from-outcome>
        <to-activity-id>edit-record</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule>
      <from-activity-id>edit-record</from-activity-id>
      <control-flow-case>
        <from-outcome>done</from-outcome>
        <to-activity-id>done</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
  </task-flow-definition>
</adfc-config>

