« Oracle ADF Code Corner: How-to scroll an ADF bound ADF Faces Table using a Keyboard Shortcut | Main | ADF Code Corner on Twitter ! »
How-to Create custom ADFc Exception Handler
By frank.nimphius | February 1, 2010
The ADFc controller provides declarative exception handling. However, if you need to customize this exception handler, for example to redirect a request to a custom session expiry page, then you can do this as follows
- Create a Java class that extends 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 the expiry example, in the handleException method, you check throwable.getMessage() for “ADF_FACES-30108″ which indicates the expiry message. Don’t forget to rethrow execptions that your custom class doesn’t handle so it can be handled by the ADFc default Exception handler.
However, You should always try and use declarative exception handling when possible. For example, a router activity that is marked as the exception handler can access a managed bean method, which then accesses the ControllerContext.getCurrentInstance(), and in here the ViewPort, for determining the Exception type and message. So keep the hint of how to extend the the ADFc controller class as an exception to the rule of using declarative excpetion handler and use it only if you can’t find out how to handle an exception it otherwise.
Configuring the ADFc custom exception handling class is not yet part of the product doumentation but will be added the next JDev 11g Patch Set as part of the task flow content.
The above hint is a brief summary excerpt taken from the Oracle Fusion Developer Guide book that Lynn Munsinger and I wrote for McGraw Hill. I am blogging this in response to a question on the JDeveloper OTN forum.
Frank
Topics: ADF Faces RC | No Comments »
Comments are closed.
