How to create your custom ExceptionHandler in Oracle ADF

Steps:

  • Create a Java class that extends oracle.adf.view.rich.context.ExceptionHandler
  • Create a textfile with the name “oracle.adf.view.rich.context.Exceptionhandler” (without the quotes) and store it in .adf\META-INF\services (you need to create the “services” folder)
  • In the file, add the absolute name of your custom exception handler class (package name and class name without the “.class” extension)

 

import oracle.adf.view.rich.context.ExceptionHandler;
public class MyCustomExceptionHandler extends ExceptionHandler {

public MyCustomExceptionHandler() {
     super();
}
public void handleException(FacesContext facesContext, 
                            Throwable throwable, PhaseId phaseId) 
                            throws Throwable{
   String error_message;
   error_message = throwable.getMessage();
   //check error message and handle it if you can
   if( … ){  
       //handle exception
       …
   }
   else{
      //delegate to the default ADFc exception handler
       throw throwable;}
   }
}

it is recommended to first try and handle exceptions with the ADF Controller default exception handling mechanism.

About Vineet Verma

Developer/Blogger/Gamer/Lazy Couch Potato...:P Need PDF Books: Knowledge Base
This entry was posted in Oracle ADF and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s