ADF: Custom Error Handler to Display Custom Message to User

ADF: Custom Error Handler to Display Custom Message to User

Sometimes user wants to display custom error message instead of default message. For such cases ADF framework provides a way to create custom error handler class which extends default DCErrorHandlerImpl class. You are not required to write any code to register your custom exception handler class. Instead, you’ve to select the root node of the DataBindings.cpx files in the Structure window, and then use the Property Inspector to set the ErrorHandlerClass property to the fully qualified name of the error handler you want to use.
In this example I’ll give the custom message for validation exception when more than one row is using same primary key. Default message displayed by ADF framework is-
JBO-25013 Too many object match primary key. And  I’ll replace it with custom message. Hear I’m using Hr schema Employees table.
Step1: Create Entity Object and View Object using Employees table.
Step2: Drag-drop this view object in jspx page as ADF table.
Step3: Create java class with which extends DCErrorHandlerImpl class.


import oracle.adf.model.binding.DCBindingContainer;

import oracle.adf.model.binding.DCErrorHandlerImpl;

import java.sql.SQLException;

import oracle.adf.model.BindingContext;

import oracle.adf.model.binding.DCBindingContainer;

import oracle.adf.model.binding.DCErrorHandlerImpl;

import oracle.jbo.JboException;



public class MyCustomErrorHandler extends DCErrorHandlerImpl {

public MyCustomErrorHandler() {




public MyCustomErrorHandler(boolean setToThrow) {





public void reportException(DCBindingContainer dCBindingContainer,

Exception exception) {

super.reportException(dCBindingContainer, exception);




public String getDisplayMessage(BindingContext ctx, Exception ex) {

String message="";

if (ex instanceof oracle.jbo.ValidationException) {


String msg = ex.getMessage();

int i=msg.indexOf("JBO-25013");//When JBO-25013 Too many object match promary key exception occur.



message= "Duplicate Employee Id Found.";


message= getDisplayMessage(ctx,ex);






return message;



getDisplayMessage(): Returns the message that will be reported to JSF for
each error that occurs. I have overridden this method and provided a custom message when JBO-25013 exception occurs, in rest of all cases it’ll give the default message.
Step4: Register MyCustomErrorHandler class into Databinding.cpx file.

<?xml version="1.0" encoding="UTF-8" ?>

<Application xmlns=""

version="" id="DataBindings" SeparateXMLFiles="false"

Package="" ClientType="Generic"



<page path="/test.jspx" usageId="com_in_adftutorials_view_testPageDef"/>



<page id="com_in_adftutorials_view_testPageDef"




<BC4JDataControl id="AppModuleDataControl"



SupportsTransactions="true" SupportsFindMode="true"

SupportsRangesize="true" SupportsResetState="true"


Configuration="AppModuleLocal" syncMode="Immediate"




Running application without registering custom error handler class.
Output when registering MyCustomErrorHandler class to databinding .cpx file.
Sample Code

About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply

Your email address will not be published. Required fields are marked *


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