IdleMonitor tracks user actions and invokes corresponding events when user goes idle after a specified time and becomes active again.
Documentation<h:form> Stay idle on this page for 5 seconds to view the demo. <p:growl id="messages" showDetail="true" sticky="true" /> <p:idleMonitor timeout="5000"> <p:ajax event="idle" listener="#{idleMonitorView.onIdle}" update="messages" /> <p:ajax event="active" listener="#{idleMonitorView.onActive}" update="messages" /> </p:idleMonitor> </h:form>
@Named @RequestScoped public class IdleMonitorView { public void onIdle() { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "No activity.", "What are you doing over there?")); } public void onActive() { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Welcome Back", "Well, that's a long coffee break!")); } }