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.
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
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 |
import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.PhaseId; import oracle.adf.view.rich.context.ExceptionHandler; public class MyExceptionHandler extends ExceptionHandler { public MyExceptionHandler() { super(); } @Override public void handleException(FacesContext facesContext, Throwable throwable, PhaseId phaseId) throws Throwable { // TODO Implement this method String error = throwable.getMessage();; //Handle the error or log the error //throw throwable; //Log it FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,error, null ); FacesContext.getCurrentInstance().addMessage(null, message); } } |
Register the Exception class
Open your ADF application in a file explorer, Go to .adf , META-DATA directory; Create a folder called ‘services’
Go into the ‘services’ directory and create a file called oracle.adf.view.rich.context.ExceptionHandler
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.
Open the file Oracle.adf.view.rich.context.ExcepionHandler and input the ExceptionHandler java class
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.
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
Open the view1.jsff page and drop a command button. The action of the button should be toException
Create an index.JSF page and drop the bounded task flow as a region activity; Run the page
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.
Govind
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 🙂
Latest posts by Govind
- How to increase the session timeout in Primavera P6 EPPM - February 28, 2018
- About Primavera P6 Jobs, P6 Job Server and P6 Services.jar - February 25, 2018
- Is it possible to logout Primavera P6 through SQL Query? - February 16, 2018
cartier like love bracelet replica
The idiot class as you call them are being pushed and manipulated by others.
bague imitation bulgari b zero
Good web site! I really love how it is simple on my eyes and the data are well written. I’m wondering how I could be notified when a new post has been made. I have subscribed to your feed which must do the trick! Have a nice day!
1:1 hermes kelly bolso orange
Talk to your health caree professional if you’ve got questions or worries about testosterone therapy.
Cheap Jerseys Store
It will provide with spray machines and hand painting. Set up new hard ware and recondition all of them with oils to make them appearance new. Within the case of iPod music downloads, you may want to do your homework and thoroughly research a web site…
Trinity De Cartier Bague copie
more or less unavailing online courses. Topics extent from selling investigate to get skin disorder. Use a form from an soul. Every causal agent should be same “implemental” in your commencement, but stay form. swan your friends as a ball performing…
HI Govind,
want help to implement above logic in my current appln.
we are using jdev 12.2.1.2.0 …my application as many functionality ..for each functionality i have created individual BTF. BTF has onpageLoad method and page fragment .page fragment has search , create operation based on requiremnt also many LOV are in it. im unable to handle uncaught exception in page fragment .everytime it gives error like this on page.
“ADF_FACES-60097:For more information, please see the server’s error log for an entry beginning with: ADF_FACES-60096:Server Exception during PPR, #1 ”
i tried implementing as u said in blog till ” 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 .”
but on exception im unable to see sop in exceptionhandler class.rather still this ppr error popup out..
can you please to implement in better way..as we have very short span for GO LIVE ..its urgent help please.
after doing too much of hard work this error msg is giving us bad impression from client..
thanq for understanding.