Sunday, October 19, 2008

Reusable ADF Task Flow exception handler

In this blog entry I will show you how powerful ADF Task Flow are and how it can save you a lot of time. You only have to build it ones and use it everywhere. In this example I use an Exception page in a bounded Task Flow as a reusable component. In every Task Flow you can define a Exception Handler which takes care of the not handled exceptions. So probably you build this exception page in every project. I only have to drag the exception Task Flow from the component palette to the Task Flow, define some input parameters and make this Exception TF the Exception handler of the application Task Tlow.
This is how my exception page looks like. The Title and the Branding are flexible so you can change it in every Task Flow ( Task Flow input parameters)

First we create a project where we add an exception JSF template. This template has two facets Top and Body and 3 attributes Title , Branding ( Image component ) and Stacktrace.
Now we can add a new deployment profile to this project , select the ADF Library JAR File and deploy this template.

Create a new project with a bounded Task Flow ( de-select the page fragments option ) . In this Task Flow we add a new view.

Add the Title and Branding input parameters to this Task Flow definition.

The next step is to add the template library so we can use the exception jsf template. Create a new page ( select the view in the TF and use the right button to create the page). In the create page dialog we can select exception template. Here is the source of the jsf page where the templates attributes are connected to the input parameter of the TF

<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="" version="2.1"
< contentType="text/html;charset=windows-1252"/>
<af:pageTemplate viewId="/templates/ExceptionTemplate.jspx">
<f:facet name="header"/>
<f:facet name="body"/>
<f:attribute name="branding" value="#{pageFlowScope.inputBranding}"/>
<f:attribute name="title" value="#{pageFlowScope.inputTitle}"/>
<f:attribute name="stacktrace" value="#{Exception.stacktrace}"/>

To get the stacktrace, I need to use a bean and pass this value to the stacktrace attribute of the jsf template

package nl.ordina.view.exception.bean;

import oracle.adf.controller.ControllerContext;

public class ExceptionBean {

private ControllerContext cc;

public ExceptionBean() {
cc = ControllerContext.getInstance();

public String getStacktrace() {
if ( cc.getCurrentViewPort().getExceptionData()!=null ) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
return sw.toString();
return null;

Add this bean as backing bean in the bounded TF.
Create a new deployment profile , select the ADF Library JAR File and deploy this Task Flow.
finally we can use this Exception page in our applications by adding the ADF library to the project and drag the exception TF to our application TF's

Make this view the exception handler

Put some values to the Title and Branding parameters and we are finished.

Here is the project code.


  1. Hi,
    if I want to catch exceptions on eo/vo to the pages, how can I do?Thanks!Best wishes!

  2. Hi Edwin,

    I tried a very simple thing for checking taskFlow exception handling.

    I created a bounded task flow with a page fragment (View1.jsff) and another view which is the TaskFlow ExceptionHandler (error.jsff).

    The view1.jsff has a button whose action is bound to the backing bean. In the backingBean method I deliberately do a division by 0.

    Since this is an unHandled exception, I would have expected the control to come to error.jsff. But, instead I am shown a pop up box with the error message.

    Why is the control not getting redirected to error.jsff ?

    S.Srivatsa Sivan

  3. Hi,

    Can you test it by adding a new page fragment and add the error method between the two page fragments and see what happens then.

    I have in the unbounded task flow a bounded task flow which has one jspx page and this TF is the exception handler in the unbounded TF

    and in a page of the unbounded TF i have call this method ( in a button )
    public String raiseException() {
    int i = 1/0;
    return null;


  4. Hi Edwin,

    The task flow exception seems to be able to catch any exceptions thrown by beans, but as soon as i had the bc model throw the exception, it still utilizes the popup.

    Does this mean i need to also override the DCErrorHandler of the task flow?



  5. Hi,

    I don't know, maybe you can ask Frank Nimphius or make a forum post / support call.

    thanks and let me know

  6. Hi there. I would like to take a look at the code for this post but can't seem to find it anywhere... :(

  7. Hi

    Here we go

    good luck

  8. Hi Edwin, I need similar exception handling mechanism for page with taskflow as regions.
    the the taskflow which gets initialized as region, i added the taskflow from the jar file(ExceptionTaskFlow.jar). But when an error occurs in the taskflow, Exceptionview.jspx is not getting rendered. Please advise