Idle
Simple user inactivity monitor for Vaadin applications
This is an extension for Vaadin to track user activity / user inactivity. Inactivity is checked by tracking mouse and keyboard moves in the whole window. After user is idle for a given period a CSS class is applied to <body> element and optionally an event is sent to the rest of the application.
This extension can be used to hide unnecessary controls when user is not active, or give a notification and/or prevent user session from expiring.
The following CSS class names are used:
- body.userinactive
- body.useractive
These can be used to chance the look and feel: animate, show or hide, gray-out or just disable some elements with CSS. This works best with 'Valo' theme.
If a listener is also given, it will be notified on activity changes. This can be used to trigger some UI changes or start/stop background tasks.
Idle timeout can be configured in milliseconds. Default is 5000 (i.e. 5 seconds).
Sample code
// Apply CSS after 15sec Idle.track(myUI, 15000);
body.userinactive { .status { color: red; } } body.useractive { .status { color: green; } }
// Apply CSS and call listener after 15sec Idle.track(this, 15000, new Idle.Listener() { @Override public void userInactive() { status.setValue("You are now idle"); } @Override public void userActive() { status.setValue("You are now active"); } }); });
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Maven pom.xml updated.
- Released
- 2014-07-17
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 7.0+
- Vaadin 7.4+ in 1.1.0
- Vaadin 8.0+ in 2.0.0
- Browser
- Browser Independent