I use a (Primefaces 3.5) logout button in my application that looks like:
<p:commandButton ajax="false" value="Logout" action="#{loginBean.logout}" />
The bean method looks like:
public String logout() {
ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
try {
request.logout();
System.out.println("Logging out!");
return "/mylogin?faces-redirect=true";
} catch (ServletException ex) {
System.out.println("Failed to logout!");
return null;
}
}
The string Logging out! is printed correctly, but the redirect is not performed!
Only when I click the logout button a second time the login page is displayed again?
Why?
Regards, G.Verhaag