i’m making a logout link and this is the code of the logout bean.
public void doLogout() {
try {
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("user_info", null);
FacesContext.getCurrentInstance().getExternalContext().redirect("../index.xhtml");
} catch (Exception e) {
}
}
in my xhtml page i have
<ul class="dropdown-menu">
<li><h:outputLink value="#{logout.doLogout()}">Logout</h:outputLink></li>
</ul>
my problem is when i get into the page, the page automatically logs me out, its invoking the logout.doLogout() method without me clicking the link itself.
i tried erasing the code inside the doLogout() and just change it to simply a Sysout, and it does invoke the method with out me clicking the link.
oh stupid of me..
<h:commandLink action="logout.doLogout()">Logout</h:commandLink>does the job.