Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Catch Exceptions In JSF Page (View) : Problems  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
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;
   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;

   public ExceptionHandler getWrapped() {
       return wrapped;

   public void handle() throws FacesException {
       Iterator iterator = getUnhandledExceptionQueuedEvents().iterator();

       while (iterator.hasNext()) {
           ExceptionQueuedEvent event = (ExceptionQueuedEvent);
           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");

           } finally {

       // Let the parent handle the rest

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  
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!