Custom Exception Handlers can be used to suppress or alter exception reporting.
1. Model Layer
Extending DCErrorHandlerImpl.http://docs.oracle.com/cd/B31017_01/web.1013/b25947/web_val008.htm
1.Create class by extending DCErrorHandlerImpl.
2.Update DataBindings.cpx
<Application xmlns="http://xmlns.oracle.com/adfm/application" version="11.1.2.60.17" id="DataBindings"
SeparateXMLFiles="false" Package="view" ClientType="Generic"
ErrorHandlerClass="view.exception.MyCustDcExceptionHandler">
3. Handle,Extend or Skip Exceptions by overriding method
public void reportException(DCBindingContainer dCBindingContainer,
Exception exception)
Got error
oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.InstantiationException, msg=view.exception.MyCustDcExceptionHandler
public MyCustDcExceptionHandler(boolean b) {
super(b); }
Change To
public MyCustDcExceptionHandler() { super(true); }
To customize known error message
@Override
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 primary key exception occur.
if(i>0)
{
message= "Duplicate Employee Id Found.";
}
message= getDisplayMessage(ctx,ex);
}
else
{
message=getDisplayMessage(ctx,ex);
}
return message;
}
References
http://adfwithejb.blogspot.com/2012/05/exception-handling-in-adf-part-1.html
http://deepak-adf.blogspot.com/2014/01/adf-exception-handling-taskflow.html
http://www.adftutorials.com/adf-custom-error-handler-to-display-custom-message-to-user.html
http://www.jobinesh.com/2011/03/customizing-business-components-error.html
http://ramannanda.blogspot.com/2011/11/error-handling-in-adf.html
2.Task Flow Exception Handler
http://fortunefusionminds.blogspot.com/2013/08/how-to-handles-exceptions-in-adf.html
http://andrejusb.blogspot.com/2010/05/handling-exceptions-in-oracle-ui-shell.html
http://biemond.blogspot.com/2008/10/reusable-adf-task-flow-exception.html
http://multikoop.blogspot.com/2014/02/adf-handling-exceptions-from_14.html
Handling Exception at adfc-config
http://multikoop.blogspot.com/2014/02/adf-handling-exceptions-from_14.html
public void handleExceptionShowMessageInPopupDialog() {
ControllerContext cc = ControllerContext.getInstance();
Exception ex = cc.getCurrentViewPort().getExceptionData();
String message = ex.getMessage();
FacesContext fc = FacesContext.getCurrentInstance();
FacesMessage facesMessage =
new FacesMessage(FacesMessage.SEVERITY_ERROR, "UTF: " + message, null);
fc.addMessage(null, facesMessage);
cc.getCurrentRootViewPort().clearException();
fc.renderResponse();
}
3.Controller Exception Handler
1)Create a Java class that extends ExceptionHandler2)Create folder .adf\META-INF\services and add file with the name oracle.adf.view.rich.context.ExceptionHandler. Save with no extension.
Under .adf\META-INF\services File Type should be EXCEPTIONHANDLER File.
3)In the file, add the absolute name of your custom exception handler class (package name and class name without the “.class” extension)
eg.
com.exchandl.view.ArCustomExceptionHandler
References
https://blogs.oracle.com/jdevotnharvest/entry/extending_the_adf_controller_exception_handler
http://www.yenlo.nl/nl/adf-11g-handling-the-adfc-12000-controllerexception-with-custom-exception-handling/
http://ramannanda.blogspot.com/2013/04/adf-exception-handling-scenario.html
ADF Errors
http://jneelmani.blogspot.com/2012/02/erroradf.html
Trace
http://marxsoftware.blogspot.com/2008/09/surprisingly-simple-stacktraceelement.html
http://marxsoftware.blogspot.com/2010/10/reading-java-stack-traces-few-tips.html
public static String accessExceptionStackTraceViaPrintWriter(final Throwable throwable)
{
final Writer writer = new StringWriter();
final PrintWriter printWriter = new PrintWriter(writer);
throwable.printStackTrace(printWriter);
return writer.toString();
}
CALFRE is the local search engine where you can find various training institutes that provide training for Oracle Fusion HCM through online in Hyderabad.
ReplyDeleteOracle Fusion Training Institute
Thank you very much. The post was long, but I loved to read it till the last word. It was so nice blog and useful to Informatics learners.
ReplyDeleteOracle Fusion Financial Training