A Timer control notifies your application when a specified period of time has elapsed or when a specified absolute time has been reached. For example, you can use a Timer control to run a process at certain intervals throughout the day, or to cancel an operation that is taking too long.
The following sections describe how to configure the Timer control.
You can specify the behavior of a Timer control in Design View by setting the control's timeout and repeats-every properties in the Property Editor window. For example, if you select a Timer control instance named delayTimer in Design View, the Property Editor window displays the following properties:
These properties correspond to attributes of the @jc:timer annotation, which identifies the Timer control in your code. The @jc:timer annotation has the following attributes:
To learn more about specifying default Timer control behavior with attributes of the @jc:timer annotation, see @jc:timer Annotation.
You can set these attributes to specify relative time. Relative time is an interval of time in relation to the present, such as three hours from now. You can also specify that the Timer control fire at an absolute time, such as 3:00 AM, by calling the Timer control's setTimeoutAt method. To learn more about specifying absolute and relative time, see Specifying Time on a Timer Control.
Once you have declared and configured a Timer control, you can invoke its methods from within your application to start and stop the timer and to change its configuration. For complete information on each method, see TimerControl Interface.
The following list contains the methods of the TimerControl interface that you can use to start and stop the timer:
The TimerControl interface also defines the following methods that you can use with a Timer control:
The Timer control defines one callback: onTimeout. You can add code to the callback handler to run when the timer fires. The callback handler for the onTimout event is named timerName_onTimeout, where timerName is the name of the Timer control instance.
The callback handler takes a single parameter, which is the time at which the callback was scheduled. Note that this is not the same as the time at which the callback handler executes. A delay may occur between Timer control expiration and callback handler invocation, depending on the system load.
To create the callback handler for a Timer control's onTimeout callback, click the onTimeout link associated with the Timer control in Design View. If a callback handler does not exist for the selected callback, WebLogic Workshop creates one, switches to Source View, and places the cursor in the callback handler for the selected callback.
Using WebLogic Built-In Controls