07 June 2011

How to create your custom oracle.adf.view.rich.context.ExceptionHandler

In a very helpful post by Frank Nimphious, it is explain how to create and declare a custom ADF Controller Exception Handler. Quoting some part below:

  • 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)
For any exception you don't handle in your custom exception handler, just re-throw it for the default handler to give it a try
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;}
   }
} 
 

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

No comments:

Post a Comment

You might also like:

Related Posts Plugin for WordPress, Blogger...
There was an error in this gadget