When I logout from my application it doesn't show my logout message
I have an outputText trying to show the message in my view (<h:outputText id="message" value="#{loginMB.message}" />
):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:o="http://omnifaces.org/ui"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/templates/template.xhtml">
<ui:define name="content">
<o:form id="login" includeViewParams="true">
<h:outputText id="message" value="#{loginMB.message}" />
... Another components ...
</o:form>
</ui:define>
</ui:composition>
And this is my backing bean:
@ManagedBean
@SessionScoped
public class UserBB implements Serializable {
private String message;
public void logout() {
try {
message = "You have been logout successfully";
SecurityUtils.getSubject().logout();
Faces.invalidateSession();
Faces.redirect("login.xhtml");
} catch (Exception exception) {
... Another code ...
}
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
Why it doesn't show my logout message?
Edit:
Logout method:
public void logout() {
SecurityUtils.getSubject().logout();
Messages.addFlashGlobalInfo("You have successfully log out");
Faces.invalidateSession();
Faces.redirect("login.xhtml?faces-redirect=true&lo=t");
}
logout button:
<p:commandButton action="#{userBB.logout}" value="log out" />