Using JDev 11.1.2.3
I have implemented a simple JSF page that I am trying to use as my global error page in my main unbounded task flow. Any exception that happens in one of my bounded task flows triggers the error handler and displays this page with the details to the user. This works fine.
The problem I have is that this page is only capturing exceptions that occur in the View layer (as I expected).
Doing some research the typical way to handle Model layer exceptions is to create a custom DCErrorHandlerImpl implementation (registered in DataBindings.cpx) to tweak the exception messages. While this does work and allows me to change the messages that come from the model layer, they still show up in popup dialog boxes on the main application. This is NOT what I want.
What I'm trying to accomplish is to push these exceptions from the model layer (DCErrorHandlerImpl) to the view layer so that my task flow exception handler page can take care of displaying the error (one single global error page for all exceptions regardless of source). Currently I have only been able to accomplish this using this ugly hack but I'm hoping I missed something obvious that would allow me to avoid doing it this way.
So the question is, is there a way to do this without resorting to my ugly hack?
Also, is there some other source of exceptions I may not be covering with this that I need to take a look at?
Thanks for looking
Important bits:
myerr.java (temporary DCErrorHandlerImpl implementation)
import oracle.adf.controller.ControllerContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCErrorHandlerImpl;
import oracle.adfinternal.controller.state.ViewPortContextImpl;
public class myerr extends DCErrorHandlerImpl {
public myerr() {
super(true);
}
public myerr(boolean b) {
super(b);
}
public void reportException(DCBindingContainer dCBindingContainer, Exception exception) {
super.reportException(dCBindingContainer, exception);
ControllerContext.getInstance().getCurrentRootViewPort().setViewId("exception"); //the error page
((ViewPortContextImpl)ControllerContext.getInstance().getCurrentRootViewPort()).setException(exception);
}
}
error.jsf page
<af:panelLabelAndMessage label="Stacktrace:" rendered="#{controllerContext.currentViewPort.exceptionPresent}"
labelStyle="vertical-align: top;">
<af:outputText value="#{ExceptionRequestBean.stacktrace}" escape="false"/>
</af:panelLabelAndMessage>
ExceptionRequestBean.java
public String getStacktrace() {
if(cc.getCurrentViewPort().getExceptionData() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
cc.getCurrentViewPort().getExceptionData().printStackTrace(pw);
return sw.toString().replaceAll("\n", "<br/>");
}
return null;
}