i want to use the idle monitor of primefaces for the session timeout. Properly it works. But the redirect to my login-page (login.xhtml it doesn't work.
I use this the idle-monitor in my body of the template of my xhtml pages: Template.xhtml
<p:idleMonitor timeout="1800000" >
<p:ajax event="idle" listener="#{pageServiceBean.timeout()}" oncomplete="alert('Die Session ist abgelaufen.')"/>
</p:idleMonitor>
The code of the pageServiceBean is: PageServiceBean.xhtml
@ManagedBean
@SessionScoped
/**Die Page-Service Bean wird in der Fußzeile der Seite eingesetzt und beinhaltet den Zurück-Button bzw. den Logout Button*/
public class PageServiceBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 3251724422690388588L;
/**Leitet auf zur Auswahlseite zurück*/
public String cancel(){
return"/sampleForDB.xhtml";
}
/**Leitet zur Loginseite zurück*/
public String cancelSampleButton(){
return"/login.xhtml";
}
public void timeout() throws IOException {
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
FacesContext.getCurrentInstance().getExternalContext().redirect("...login.xhtml");
}
}
I have no redirect to the login.xhtml. But the user ist logged out. So the stuff is not valid any more. The to other function (cancel and cancelSampleButton) works. So they navigate to the correct page.
I looked at the answer from Answer in another post But that don't fixed my problem.
In this post the person speaks to set the time in the web.xml. But i don't no which code did i write in the xhtml.
And i don't know what does the three dots in the redirect method do FacesContext.getCurrentInstance().getExternalContext().redirect("...login.xhtml");
Any idea?