Flash created in ExceptionHandler not work
------------------------------------------

                 Key: MYFACES-3358
                 URL: https://issues.apache.org/jira/browse/MYFACES-3358
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-314
    Affects Versions: 2.1.3
         Environment: WebSphere 8.0
            Reporter: Keith Wong


I have a custom ExceptionHandler for handling ViewExpiredException as occurred 
in session timeout or application restart.  I have to tell the user in the 
redirected page the reason for being redirected.  Here is the handler:

        public void handle() throws FacesException {
                for (Iterator<ExceptionQueuedEvent> 
i=getUnhandledExceptionQueuedEvents().iterator(); i.hasNext(); ) {
                        ExceptionQueuedEventContext context = 
i.next().getContext();
                        Throwable t = context.getException();
                        if (t instanceof ViewExpiredException) {
                                FacesContext ctx = 
FacesContext.getCurrentInstance();
                                ViewExpiredException vee = 
(ViewExpiredException)t;
                                try {
                                        ctx.addMessage(null, new 
FacesMessage(FacesMessage.SEVERITY_ERROR, vee.getClass().getName(), 
vee.getMessage()));
                                        Flash flash = 
ctx.getExternalContext().getFlash();
                                        flash.put("expiredViewId", 
vee.getViewId());
                                        flash.setKeepMessages(true);

                                        
ctx.getApplication().getNavigationHandler().handleNavigation(ctx, null, 
"/login?faces-redirect=true");
                                        ctx.renderResponse();
                                }
                                finally {
                                        i.remove();
                                }
                        }
                }
                super.handle();
        }

In the login.xhtml, it has #{flash.expiredViewId} and <f:messages> but both are 
empty when displayed.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to