Saturday, August 31, 2013

ADF Task FLow Call Activity Listeners

Task flow call activity can before and after listeners.These listeners identify the start and end of the bounded task flow.The listener method cannot take parameters.Control flow must return from bounded task flow using control flow rule to execute the after listener.User leaves bounded task flow using browser back button or entering to other URL the after listener won't be called.Need to use task flow finalizers to release resources in this case.
Create a called task flow with task flow return activity
listener_called_view1.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:panelGroupLayout id="pgl1">
    <af:outputText value="Called Listener" id="ot1"/>
    <af:button text="Return" id="b1" action="toReturn"/>
  </af:panelGroupLayout>

</jsp:root>

Create a calling Task flow 
listener_view1.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:panelGroupLayout id="pgl1">
    <af:outputText value="TF Listeners" id="ot1"/>
    <af:button text="button 1" id="b1" action="toCall"/>
  </af:panelGroupLayout>
</jsp:root>

Create a managed bean in request scope as below 
package test.view;


public class TFCallActivityListeners {
    public TFCallActivityListeners() {
        super();
    }

    public void beforeListerner() {
        System.out.println("Before listener called ");

    }

    public void afterListener() {
        System.out.println("After listener called ");
    }
}
Drag and drop the calling task flow to the jspx page as a region and run the page. Click on the buttons in the views.Note the listeners are executed and see the messages in the log.

No comments:

Post a Comment