We purposely kept idle timeout very low (3 sec) for testing our example.
Managed Bean
@ManagedBean
@ViewScoped
public class UserBean {
private List<String> logs = new ArrayList<>();
public void onIdle(AjaxBehaviorEvent ae) {
logs.add("idle: " + LocalDateTime.now());
}
public void onActive(AjaxBehaviorEvent ae) {
logs.add("active: " + LocalDateTime.now());
}
public List<String> getLogs() {
return logs;
}
}
output
To try examples, run embedded tomcat (configured in pom.xml of example project below):
mvn tomcat7:run
On going idle multiple times and activate browser window again:
On Chrome developer console:
Example Project
Dependencies and Technologies Used:
primefaces 6.2:
PrimeFaces is one of the most popular UI libraries in Java EE Ecosystem and widely used by software companies, world renowned brands, banks, financial institutions, insurance companies, universities and more.
[Description from primefaces-6.2.pom]
jsf-api 2.2.14:
This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.
jsf-impl 2.2.14:
This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.