Does NavigationHandler.handleNavigation() clear the flash?

Posted by kgrad on Stack Overflow See other posts from Stack Overflow or by kgrad
Published on 2010-05-20T14:56:41Z Indexed on 2010/05/20 15:20 UTC
Read the original article Hit count: 209

Filed under:
|
|

I am using JSF2.0 Mojarra 2.0.2.

I have a method that logs out a user and puts a logout message in the flash, forwards to the login page (which has a div that prints out the flash). However, when I use navigationHandlers handleNavigation method for some reason the flash is not being displayed. I have a similar method that forwards a user to the login page if he/she isn't logged in.

If I handle the navigation through an h:link and just call the logout method directly, the flash is displayed as normal, but if I use the handleNavigation() method, the flash is cleared for some reason.

The code in question is:

public void performLogout()
{
    getFacesContext().getExternalContext().invalidateSession();
    setCurrentUser(null);
    getFlash().put("notice", "Successfully logged out.");
    super.getFacesContext().getApplication().getNavigationHandler()
            .handleNavigation(getFacesContext(), null, "login");
}

Is there some way I can keep the flash when navigating like this?

thanks.

© Stack Overflow or respective owner

Related posts about jsf

Related posts about java