I checked a dozen of answers on similar question to this one, but none helped me solve the issue.
Here is the body .xhtml file, where logout button does not work. This page is shown after login, if that is relevant.
<body>
<h:form id="newTaskForm">
<center>
<p:commandButton value="Logout" action="#{LogoutController.logout}"/>
</center>
<p:panel id="panel" header="New task" style="margin-bottom:20px">
<h:panelGrid id="grid" cellpadding="5" columns="3" style="margin-bottom:10px">
<f:facet name="header">
<p:messages id="msgs" />
</f:facet>
form stuff, this is ok
<p:commandButton action="#{createNewTaskController.saveTask}"
value="Spremi zadatak" update="newTaskForm" />
</h:panelGrid>
</p:panel>
</h:form>
and here is a bean:
@SessionScoped
@ManagedBean
public class LogoutController {
public String logout() {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
.getExternalContext().getSession(true);
session.invalidate();
return "/createNewTask.xhtml?faces-redirect=true";
}
}
I've seen a list of possible reasons why it could not work, but I can't really tell what an actual reason is, so I'd be grateful for any help