Friday, October 4, 2013

ADF 11G : How to Customize Default ADF BC Error Messages?

ADF 11G : How to Customize Default ADF BC Error Messages?










Class under Model:
package model;

import java.util.ListResourceBundle;

public class NeelmaniCustomModelMessageBundle extends ListResourceBundle {
    private static final Object[][] emp_email_UK =    new String[][] { { "EMP_EMAIL_UK", "This Email is already Taken by other Employees!"} };


    protected Object[][] getContents() {
        return emp_email_UK;
    }
}




Class under ViewController:
package view;

import java.sql.SQLIntegrityConstraintViolationException;

import oracle.adf.model.binding.DCErrorHandlerImpl;

import oracle.jbo.DMLConstraintException;

public class NeelmaniErrorHandler extends DCErrorHandlerImpl {
    public NeelmaniErrorHandler() {
    super(false);
    }
    public NeelmaniErrorHandler(boolean b) {
    super(b);
    }

    @Override
    protected boolean skipException(Exception exception) {
        if (exception instanceof DMLConstraintException) {
        return false;
        } else if (exception instanceof
        SQLIntegrityConstraintViolationException) {
        return true;
        }
      
    
        return super.skipException(exception);
    }
}