Wednesday Jun 27, 2012

Using Exception Handler in an ADF Task Flow

Problem Statement:

Exception thrown in a task flow gets wrapped in an exception that gives an unintelligible error message to the user.

Figure 1

Solution 1. Over-writing the error message with a user-friendly error message.

Figure 2


Steps to code

1. Generating an exception: Write a method that throws an exception and drop it in the task flow.
2. Adding an Exception Handler: Write a method (example below) to overwrite the Error in the bean or data control and drop the method in the task flow.

Figure 3

This method is marked as the Exception Handler by Right-Click on method > Mark Activity> Exception Handler or by the button that is displayed in this screenshot

Figure 4

The Final task flow should look like this. This will overwrite the exception with the error message in figure 2.
Note: There is no need for a control flow between the two method calls (as shown below).

Figure 5

Solution 2: Re-Routing the task flow to display an error page

Figure 6

Steps to code

1. This is the same as step 1 of solution 1.
2. Adding an Exception Handler: The Exception handler is not always a method; in this case it is implemented on a task flow return.  The task flow looks like this.

Figure 7

In the figure below you will notice that the task flow return points to a control flow ‘error’ in the calling task flow.

Figure 8

This control flow in turn goes to a view ‘error.jsff’ which contains the error message that one wishes to display.  This can be seen in the figure below. (‘withErrorHandling’ is a  call to the task flow in figure 7)

Figure 9

About

ADF Tips and Tricks

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today