This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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

 
Greenhorn
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;
   }
   
   @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  
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!