终于得到了我在p:idleMonitor
这里使用的解决方案。它会在内部照顾
<p:idleMonitor timeout="#{login.sessionTimeoutInterval}">
<p:ajax event="idle" listener="#{login.sessionIdleListener}" />
</p:idleMonitor>
<p:confirmDialog closable="false" id="sessionExpiredDlg"
message="Your session expired."
header="#{msgs['confirmDialog.initiatingDestroyProcess.label']}"
severity="alert" widgetVar="sessionExpiredConfirmation" style="z-index: 25000">
<p:commandButton id="confirmRouteDel" value="Ok"
oncomplete="sessionExpiredConfirmation.hide()"
actionListener="#{login.logoutAction}"/>
Java方法:
public void sessionIdleListener() {
RequestContext context = RequestContext.getCurrentInstance();
context.execute("sessionExpiredConfirmation.show()");
}
看看这个一次。
http://www.primefaces.org/showcase/ui/misc/idleMonitor.xhtml
它有两个例子。