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 .adfMETA-INFservices (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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.