timer
timer facet is designed to run UI code at specified time intervals.
The timer action is initiated from the browser as a user request and its handler can update UI components. The timer stops working when the view it was created for is closed.
Basic Usage
Add timer to the facets element of the view XML descriptor:
<facets>
<timer id="timer" delay="3000" autostart="true" repeating="true"/>
</facets>
Create TimerActionEvent handler:
@Autowired
private Notifications notifications;
@Subscribe("timer")
public void onTimerTimerAction(final Timer.TimerActionEvent event) {
notifications.show("Timer action");
}
The handler will be invoked every 3 seconds after the view is opened.
Attributes
timer is defined in the facets element of the view XML descriptor and has the following attributes:
Handlers
|
To generate a handler stub in Jmix Studio, use the Handlers tab of the Jmix UI inspector panel or the Generate Handler action available in the top panel of the view class and through the Code → Generate menu (Alt+Insert / Cmd+N). |
TimerActionEvent
TimerActionEvent is triggered after the specified time interval in the delay attribute has passed since the timer started. If the repeating attribute is set to true, this event is sent periodically, until the timer is stopped.
To register the event handler programmatically, use the addTimerActionListener() method of the facet.