13 total views, 4 views today

Oracle ADF Exception Handling – example

In my previous, ADF exception handling post, I have described how to catch an exception that is thrown inside a task flow. This post I am sharing about creating a custom Exception handler java class that will catch any unhandled exception thrown inside the ADF application. Using this we can catch any unhandled ADF exception, orlog the exception in a log file or delegate this exception to it successor. Basically, the custom exceptionHandler java class is extended to oracle.adf.view.rich.context.ExceptionHandler

In this example, I have created a bounded task flow with a view activity and method call activity. The view activity has a command button which calls the method action which throws a JBO exception. The exception will be caught in a custom exception class.

080916_0216_OracleADFEx1 Oracle ADF Exception Handling – example

Download the ADFExceptionHandler

Let’s begin the example,

Create a custom ExceptionHandler class

Expand the view controller and create a java class the extends oracle.adf.view.rich.context.ExceptionHandler. Override the method handleException and write the exceptional logic, logger or delegation inside the method . I have used the facesmessage to display the error in a popup

 

Register the Exception class

Open your ADF application in a file explorer, Go to .adf , META-DATA directory; Create a folder called ‘services’

080916_0216_OracleADFEx2 Oracle ADF Exception Handling – example

Go into the  ‘services’ directory and create a file called oracle.adf.view.rich.context.ExceptionHandler

080916_0216_OracleADFEx3 Oracle ADF Exception Handling – example

Now open the JDeveloper, Refresh the application; Expand Application Resources, Description, ADF META-INF and check the services directory and file we created in the previous steps are visible.

080916_0216_OracleADFEx4 Oracle ADF Exception Handling – example

Open the file Oracle.adf.view.rich.context.ExcepionHandler and input the ExceptionHandler java class

080916_0216_OracleADFEx5 Oracle ADF Exception Handling – example

That’s it. We are done with creating custom exceptional handling class and register it .if any unhandled exception rises inside the app will get caught in the registered method .

You can skip the below steps if you understand the exceptional handler.

I have created a java class called ThrowException under view controller which has one method, which throws a JBO exception. Expose the method by right click on the class and select Generate Data controller.

080916_0216_OracleADFEx6 Oracle ADF Exception Handling – example

Create a bounded task flow; Drop the exposed method from data control pallate to the task flow and drop a view activity. Using control flow case, drag a line from view to method call activity and mark it ‘toException’ as shown below. Create a JSFF page from the view activity

080916_0216_OracleADFEx7 Oracle ADF Exception Handling – example

Open the view1.jsff page and drop a command button. The action of the button should be toException

080916_0216_OracleADFEx8 Oracle ADF Exception Handling – example

Create an index.JSF page and drop the bounded task flow as a region activity; Run the page

080916_0216_OracleADFEx9 Oracle ADF Exception Handling – example

On clicking on the method will call the method ‘throwException’ method which throws a JBO exception. The exception got caught by the custom exceptionalHandler class.

080916_0216_OracleADFEx10 Oracle ADF Exception Handling – example


govindan Oracle ADF Exception Handling – example
Connect me

Govind

Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
govindan Oracle ADF Exception Handling – example
Connect me
Like us on Facebook.
Connect!