Wednesday, 28 May 2008

JDev 11gTP4 customising the DCErrorHandlerImpl class

As per section 27.8 of the JDev ADF Guide 11g for TP4, you're allowed to customise the DCErrorHandlerImpl. This is done by creating your own customised handler class extending DCErrorHandlerImpl, than adding a reference in the ViewController's DataBindings.cpx file.

An example class:

package view.controller.frameworkExtension;

import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCErrorHandlerImpl;

class ErrorHandlerImpl extends DCErrorHandlerImpl {
  public ErrorHandlerImpl() { super(true); }

  public void reportException(DCBindingContainer dCBindingContainer, Exception exception) {
    super.reportException(dCBindingContainer, exception);

On opening the DataBindings.cpx file, selecting the DataBindings node in the structure window, then the ErrorHandlerClass property in the property inspector, and entering your custom package.class name (ie. view.controller.frameworkExtension.ErrorHandlerImpl), you may receive the following error in a dialog:

view.controller.frameworkExtension.ErrorHandlerImpl not an instance of oracle.adf.model.binding.DCErrorHandlerImpl

Or alternatively you may bypass the property inspector and enter the property in the DataBindings.cpx file, and at runtime receive the following Java error:

JBO-29000: Unexpected exception caught: java.lang.IllegalAccessException, msg=Class oracle.jbo.common.JBOClass can not access a member of class view.controller.frameworkExtension.ErrorHandlerImpl with modifiers "public"

The basic error here is being raised because your custom error handler class is not "public". Simply change the class to be publically accessible, such as:

public class ErrorHandlerImpl extends DCErrorHandlerImpl {

If you're interested on finding more help on JDeveloper errors, visit the Understanding ADF Error Codes page.

No comments: