I have two Classes that extend from ExceptionHandlerWrapper & ExceptionHandlerFactory for catching any exceptions that occur in the view layer and navigate to error page and show this error. So I need store or save this exceptions somewhere but I can`t get this exception message. I tried to get this message in session but I need another way to save this message with out ViewScope and PageFlowScope and RequestScope.
public class CustomExceptionHandlerFactory extends ExceptionHandlerFactory {
private ExceptionHandlerFactory parent;
public CustomExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler result = new CustomExceptionHandler(parent.getExceptionHandler());
return result;
}
}
public class CustomExceptionHandler extends ExceptionHandlerWrapper {
private ExceptionHandler wrapped;
public CustomExceptionHandler(ExceptionHandler wrapped) {
this.wrapped = wrapped;
}
@Override
public ExceptionHandler getWrapped() {
return wrapped;
}
@Override
public void handle() throws FacesException {
Iterator iterator = getUnhandledExceptionQueuedEvents().iterator();
while (iterator.hasNext()) {
ExceptionQueuedEvent event = (ExceptionQueuedEvent) iterator.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable throwable = context.getException();
FacesContext fc = FacesContext.getCurrentInstance();
Map<
String, Object> sessionMap = fc.getExternalContext().getSessionMap();
NavigationHandler navigator = fc.getApplication().getNavigationHandler();
AdfFacesContext adfc = AdfFacesContext.getCurrentInstance();
// Map<String,Object> valueViewScope = adfc.getViewScope();
try {
// Flash flash = fc.getExternalContext().getFlash();
// Put the exception in the flash scope to be displayed in the error
// page if necessary ...
// flash.put("errorDetails", throwable.getMessage());
// ADFContext.getCurrent().getSessionScope().put("errorDetails", throwable.getMessage());
sessionMap.put("errorDetails", throwable.getMessage());
System.out.println("the error is put in the Session: " + throwable.getMessage());
//NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigator.handleNavigation(fc, null, "ErrorPage?faces-redirect=true");
// navigationHandler.handleNavigation(fc, null, "ErrorPage?faces-redirect=true");
fc.renderResponse();
} finally {
}
}
// Let the parent handle the rest
getWrapped().handle();
}
}
Please I need Another Way To Store - or Save This Value
In SessionScope But i Need Another Way
WithOut Any Value In Session Beacuse Will Get Null in Bean
But In Page Error Showd successfully
because value in session