【发布时间】:2014-07-31 11:53:00
【问题描述】:
我想使用 primefaces 的空闲监视器来进行会话超时。 它正常工作。但是重定向到我的登录页面(login.xhtml 它不起作用。
我在我的 xhtml 页面模板正文中使用了这个空闲监视器: 模板.xhtml
<p:idleMonitor timeout="1800000" >
<p:ajax event="idle" listener="#{pageServiceBean.timeout()}" oncomplete="alert('Die Session ist abgelaufen.')"/>
</p:idleMonitor>
pageServiceBean的代码是: 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");
}
}
我没有重定向到 login.xhtml。但用户已注销。所以这些东西不再有效。到其他功能(取消和cancelSampleButton)的作品。所以他们导航到正确的页面。
我查看了Answer in another post 的答案,但这并没有解决我的问题。
在这篇文章中,这个人说要在 web.xml 中设置时间。但我不知道我在 xhtml 中写了哪些代码。
而且我不知道重定向方法中的三个点是做什么的FacesContext.getCurrentInstance().getExternalContext().redirect("...login.xhtml");
有什么想法吗?
【问题讨论】:
标签: jsf-2 primefaces