Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to handle Database error messages in ADF?

GadoMar 18 2017 — edited Mar 19 2017

Hello Experts,

I'm using JDev 11.1.1.7.0

In one of my Database table i have a unique key constraint.

When the UK is violated it shows this message to the user:

UK Error.jpg

As you can see it doesn't look very nice.

I want to make it look better than this and not to share too much info with the user.

The page that displays this error is a page Fragment from a TF that is used as a region in the mainPage.

I tried creating a DCErrorHandlerImpl extended class following this tutorial: ADF: Custom Error Handler to Display Custom Message to User | ADF Tutorials

But it still displays the same message.

This is the class i created:

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() {

this(true);

}

public MyCustomErrorHandler(boolean setToThrow) {

super(setToThrow);

}

@Override

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-26048");//When JBO-26048 UK Constraint Violated.

if(i>0) {

message= "Duplicate Product Entry Detected.";

}

message= getDisplayMessage(ctx,ex);

} else {

message=getDisplayMessage(ctx,ex);

}

return message;

}

}

What did i do wrong?

Thank you for your time

Gado

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2017
Added on Mar 18 2017
2 comments
1,604 views