Task Flows in Popups / Dialogs

510-479x250.png

Task Flows can be executed as Dialog as following:

  • Being a Bounded Task Flow based on pages instead of fragments and used as Task Flow Call configured as inline-popup.

     

    TF Call Inline Popup
    TF Call Inline Popup


  • Using a Bounded Task Flow inside of an af:popup

    <af:panelgrouplayout id="pgl1" layout="vertical">
        <af:panelheader id="ph1" text="Sample calling a Task Flow as dialog inside of an af:popup">
          <af:panelgrouplayout id="pgl2" layout="vertical"> <af:commandbutton id="cb1" text="Call Task Flow in af:popup">
            <af:showpopupbehavior popupid="p1" triggertype="action">
          </af:showpopupbehavior></af:commandbutton>
          <af:panelgrouplayout id="pgl3" layout="vertical" partialtriggers="cb1">
            <!-- List returned by the Contextual Event thrown by the Region of the popup -->
            <af:iterator id="i1" value="#{pageFlowScope.returnedNames}" var="name">
              <af:outputtext id="ot1" value="#{name}">
            </af:outputtext></af:iterator>
          </af:panelgrouplayout>
        </af:panelgrouplayout>
    </af:panelheader>
    <!-- Popups section -->
    <af:popup contentdelivery="lazyUncached" id="p1" popupcanceledlistener="#{backingBeanScope.e_m_s_v_c_ct_callerTwoBean.cancelPopup}" popupfetchlistener="#{backingBeanScope.e_m_s_v_c_ct_callerTwoBean.fetchPopup}">
        <!--The Region will be the responsible of closing the Dialog/Popup to send back the data -->
        <af:dialog closeiconvisible="false" dialoglistener="#{backingBeanScope.e_m_s_v_c_ct_callerTwoBean.dialogListener}" id="d1" title="Region in Popup" type="none">
          <af:region id="r1" value="#{bindings.taskflowdialogasregion1.regionModel}">
        </af:region></af:dialog>
      </af:popup>
    </af:panelgrouplayout>

Pros and Cons

Solution One: TF-Call as inline-popup (based on Pages JSPX)

Pros:

  • Task Flow can return values in the Return Value parameters.

Cons:

  • It difficults to add custom styling (styleClass to af:popup or af:dialog).
  • The Task Flow can not be used as Region.

Solution Two: Using Region inside of an af:popup

Pros:

  • It can be reused as Region.
  • It is easier to apply styleClass to components like af:popup / af:dialog

Cons:

  • It can not return values using the parameters configured in Return Values. In case of returning values then an strategy of Contextual Events, Sharing a Bean or a regionNavigationListener should be used instead.
  • Refresh Task Flow will require activation

The sample

Link to the GitHub Repository containing the sample

This sample requires some ADF 11gR1 knowledge to be understood.
Each solution can be shown by the following test pages:

  • testPopupInTFCall.jspx: Executes the Solution One based on a TF-Call. Important things that have to be considered:
    • The button uses the property useWindow="true" to execute in dialog mode.

      <af:commandbutton action="irDialogo" id="cb1" text="Call Task Flow" usewindow="true">
      </af:commandbutton>


    • It returns the values configured in the Return Value parameters.

       

      Return Value Definitions
      Return Value Definitions

       

       

      Mapping the Return Values in a TF Call
      Mapping the Return Values in a TF Call

       

  • testPopupInRegion.jspx: Demostrates the Solution Two based on a Region inside of an af:popup. Things that have to be considered:
    • Activation policy that will control the activation/deactivation of the Task Flow when opening / cancelling the popup.

       

      Activation property of the Task Flow
      Activation property of the Region
    • Uses Contextual Events to return values to the caller (The invoked Task Flow fires a Contextual Event programmatically before dimissing).

      <pagedefinition id="callerSampleTwoPageDef" package="fragments.flows.tfRegionInPopup" version="11.1.1.64.93" xmlns="http://xmlns.oracle.com/adfm/uimodel">
          <parameters>
          <executables>
              <variableiterator id="variables">
              <taskflow activation="conditional" active="#{empty pageFlowScope.activation ? 'false' : pageFlowScope.activation}" id="taskflowdialogasregion1" taskflowid="/WEB-INF/flows/tfRegionInPopup/task-flow-dialog-as-region.xml#task-flow-dialog-as-region" xmlns="http://xmlns.oracle.com/adf/controller/binding">
                       <parameters>
                      <parameter id="isPopup" value="#{true}">
                  </parameter></parameters>
              </taskflow>
          </variableiterator></executables>
          <bindings>
              <methodaction action="invokeMethod" datacontrol="ContextualEventHandlerDC" id="handleReturnEvent" instancename="ContextualEventHandlerDC.dataProvider" isviewobjectmethod="false" methodname="handleReturnEvent" requiresupdatemodel="true">
                  <nameddata ndname="names" ndtype="java.util.List">
              </nameddata></methodaction>
          </bindings>
          <eventmap xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
              <event name="returnDialogEvent">
                  <producer region=" taskflowdialogasregion1.dialogRegionViewPageDef.returnDialogEventBinding">
                      <consumer handlecondition="" handler="handleReturnEvent" region="">
                          <parameters>
                              <parameter name="names" value="#{payLoad}">
                          </parameter></parameters>
                      </consumer>
                  </producer>
              </event>
          </eventmap>
       </parameters>
      </pagedefinition>


      public void performClose(ActionEvent ae) {
       // Execute the Contextual Event programmatically before of unloading the popup
       BindingContainer bindingContainer = BindingContext.getCurrent().getCurrentBindingsEntry();
       JUEventBinding eventBinding = (JUEventBinding)bindingContainer.get("returnDialogEventBinding"); 
       ActionListener actionListener = (ActionListener)eventBinding.getListener(); 
       actionListener.processAction(ae); 
        
       // Check the Input Parameter if the TF has to be considered as executed in popup
       AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
       Map<string object=""> flowScope = adfFacesContext.getPageFlowScope();
       Boolean isPopup = (Boolean)flowScope.get("isPopup");
       if (isPopup != null && isPopup) {
        this.closePopup(ae);
       }
      }


      public final class ContextualEventHandlerDC {
           
          /**
           * Default Constructor
           */
          public ContextualEventHandlerDC() {
              super();
          }
           
          /**
           * Get the list of names returned by the Contextual Event
           * @param names
           */
          public void handleReturnEvent(List&lt;string&gt; names) {
              for (String s: names) {
                  System.out.println(s);
              }
              AdfFacesContext.getCurrentInstance().getPageFlowScope().put(&quot;returnedNames&quot;, names);
          }
      }

Sample built using JDeveloper 11.1.1.7

Subscribe to email updates

Recent Posts