This is how my exception page looks like. The Title and the Branding are flexible so you can change it in every Task Flow ( Task Flow input parameters)
First we create a project where we add an exception JSF template. This template has two facets Top and Body and 3 attributes Title , Branding ( Image component ) and Stacktrace.
Now we can add a new deployment profile to this project , select the ADF Library JAR File and deploy this template.
Create a new project with a bounded Task Flow ( de-select the page fragments option ) . In this Task Flow we add a new view.
Add the Title and Branding input parameters to this Task Flow definition.
The next step is to add the template library so we can use the exception jsf template. Create a new page ( select the view in the TF and use the right button to create the page). In the create page dialog we can select exception template. Here is the source of the jsf page where the templates attributes are connected to the input parameter of the TF
<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=windows-1252"/>
<f:view>
<af:document>
<af:form>
<af:pageTemplate viewId="/templates/ExceptionTemplate.jspx">
<f:facet name="header"/>
<f:facet name="body"/>
<f:attribute name="branding" value="#{pageFlowScope.inputBranding}"/>
<f:attribute name="title" value="#{pageFlowScope.inputTitle}"/>
<f:attribute name="stacktrace" value="#{Exception.stacktrace}"/>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
</jsp:root>
To get the stacktrace, I need to use a bean and pass this value to the stacktrace attribute of the jsf template
package nl.ordina.view.exception.bean;
import java.io.PrintWriter;
import java.io.StringWriter;
import oracle.adf.controller.ControllerContext;
public class ExceptionBean {
private ControllerContext cc;
public ExceptionBean() {
cc = ControllerContext.getInstance();
}
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();
}
return null;
}
}
Add this bean as backing bean in the bounded TF.
Create a new deployment profile , select the ADF Library JAR File and deploy this Task Flow.
finally we can use this Exception page in our applications by adding the ADF library to the project and drag the exception TF to our application TF's
Make this view the exception handler
Put some values to the Title and Branding parameters and we are finished.
Here is the project code.
Hi,
ReplyDeleteif I want to catch exceptions on eo/vo to the pages, how can I do?Thanks!Best wishes!
Hi Edwin,
ReplyDeleteI tried a very simple thing for checking taskFlow exception handling.
I created a bounded task flow with a page fragment (View1.jsff) and another view which is the TaskFlow ExceptionHandler (error.jsff).
The view1.jsff has a button whose action is bound to the backing bean. In the backingBean method I deliberately do a division by 0.
Since this is an unHandled exception, I would have expected the control to come to error.jsff. But, instead I am shown a pop up box with the error message.
Why is the control not getting redirected to error.jsff ?
Thanks.
S.Srivatsa Sivan
Hi,
ReplyDeleteCan you test it by adding a new page fragment and add the error method between the two page fragments and see what happens then.
I have in the unbounded task flow a bounded task flow which has one jspx page and this TF is the exception handler in the unbounded TF
and in a page of the unbounded TF i have call this method ( in a button )
public String raiseException() {
int i = 1/0;
return null;
}
thanks
Hi Edwin,
ReplyDeleteThe task flow exception seems to be able to catch any exceptions thrown by beans, but as soon as i had the bc model throw the exception, it still utilizes the popup.
Does this mean i need to also override the DCErrorHandler of the task flow?
Thanks!
-Marvin
Hi,
ReplyDeleteI don't know, maybe you can ask Frank Nimphius or make a forum post / support call.
thanks and let me know
Hi there. I would like to take a look at the code for this post but can't seem to find it anywhere... :(
ReplyDeleteHi
ReplyDeleteHere we go
http://www.sbsframes.nl/jdeveloper/11gTemplates.zip
good luck
Hi Edwin, I need similar exception handling mechanism for page with taskflow as regions.
ReplyDeletethe the taskflow which gets initialized as region, i added the taskflow from the jar file(ExceptionTaskFlow.jar). But when an error occurs in the taskflow, Exceptionview.jspx is not getting rendered. Please advise