Я получаю IllegalStateException при перенаправлении из события preRenderView. Я работал над этим, просто запустив исключение. Есть ли более чистый способ добиться того же результата?
@Named
@RequestScoped
public class LogoutBean implements Serializable
{
    public void preRenderView(ComponentSystemEvent e)
    {
        userSessionBean.logout();
        FacesContext ctx = FacesContext.getCurrentInstance();
        try
        {
            ctx.getApplication().getNavigationHandler().handleNavigation(ctx, null, "/pages/index?faces-redirect=true");
        }
        catch (IllegalStateException exc)
        {
            // Ignore. This exception is caused by redirecting after the response is already committed. The redirect works anyway.
        }
    }
    @Inject
    private UserSessionBean userSessionBean;
}
