Hello Smart People =D
I am using Jdevelepor 11g Release 1.
Trying to understand Exception Handling here...forgive me but I am new to developing! =(
Okay so as far as I can understand, there should be mainly two types of errors that we need to handle..Model Project errors and View controller errors. Correct?
View controller errors are in the beans,etc. I have implemented Andrejus Baranovski's
method for that.
So firstly, am I right so far with ViewController error handling?
Now for the Model project, I have three java classes.
CustomErrorHandler.java
public class CustomErrorHandler extends DCErrorHandlerImpl{
List<ExceptionMapper> exceptionMapperList = new ArrayList<ExceptionMapper>();
public CustomErrorHandler() {
this(true);
}
public CustomErrorHandler (boolean setToThrow) {
super(setToThrow); }
public void reportException (DCBindingContainer bc, Exception ex) {
System.out.println ("## Custom exception handler reportException() ##");
// disableAppendCodes(ex);
super.reportException(bc, ex);
}
public String getDisplayMessage(BindingContext ctx, Exception th) {
System.out.println ("## Custom exception handler getDisplayMessage() ##");
FacesContext fctx = FacesContext.getCurrentInstance();
UIViewRoot newPage = fctx.getApplication().getViewHandler().createView(fctx,"/ErrorPage.jspx");
fctx.setViewRoot(newPage);
fctx.renderResponse();
return super.getDisplayMessage(ctx, th);
}
}
FormsPageLifecycle.java
public class FormsPageLifecycle extends FacesPageLifecycle{
public FormsPageLifecycle() {
super();
}
public void prepareModel (LifecycleContext ctx) {
if (!(ctx.getBindingContext().getErrorHandler() instanceof CustomErrorHandler)) {
ctx.getBindingContext().setErrorHandler(new CustomErrorHandler (true));
}
super.prepareModel(ctx);
}
}
FormsPhaseListener.java
public class FormsPhaseListener extends ADFPhaseListener{
/**
* @return
*/
protected PageLifecycle createPageLifecycle() {
return new FormsPageLifecycle();
}
public FormsPhaseListener() {
}
}
Now I run this and the mainPage opens all good. The error handling of course does not work.
So I go to the faces-config.xml to register my phaselistener in the lifecycle page. However, when I run my mainPage now, it does not open...just displays a blank screen with no exceptions on the log either.
Can anyone really really help me out here?
Thanks
H