Creating a New Timer Control

This topic describes how to create a new Timer control. Timer controls are declared locally in a web service's JWS file, so you do not need to create a CTRL file in order to define a Timer control.

To learn about Timer controls, see Timer Control: Using Timers in Your Web Service.

To learn about WebLogic Workshop controls, see Controls: Using Resources from a Web Service.

Creating a New Timer Control

  1. If you are not in Design View, click the Design View tab.

  2. From the Add Control drop-down list in the upper-right corner of Design View, select Add Timer Control. The Add Timer Control dialog opens, as shown here:

  1. In the Variable name for this control field, type the name of the new control. The name you enter must be a valid Java identifier.

  2. In the timeout field, specify the amount of time you want to elapse before the timer fires the first time.

  3. In the repeats-every field, specify the interval between firings after the Timer fires the first time.

  4. Choose whether or not you want to make this a control factory by selecting or clearing the Make this a control factory that can create multiple instances at runtime checkbox. For more information about control factories, see Control Factories: Managing Collections of Controls.

  5. Click Create.

As with all controls, when you add a control to your web service, WebLogic Workshop adds the declaration of an instance of the control class to your JWS file. In the case of Timer controls, the control is always of class weblogic.jws.control.TimerControl.

For more information about the Add Timer Control dialog, see Add Timer Control Dialog.

Timer Control Declarations

In the JWS file, the declaration appears as shown here:

import weblogic.jws.control.TimerControl;
...
/**
 * @jws:control
 * @jws:timer timeout="5 seconds" repeats-every="5 seconds"
 */
TimerControl delayTimer;

The actual attributes that are present on the @jws:timer tag depend on the values you entered in the Add Timer Control Dialog. For a description of the fields in the Add Timer Control dialog, see Add Timer Control Dialog.

The @jws:control tag informs WebLogic Workshop that the associated declaration is a control. Without this tag, the control will not be properly connected to supporting code and will not function.

For more information on the @jws:control tag, see @jws:control Tag.

The @jws:timer tag controls the behavior of the Timer control. All of the attributes of the @jws:timer tag are optional and have default values.

For more information on the @jws:timer tag, see @jws:timer Tag.

The Timer control, named myTimer in the example above, is declared as an instance of TimerControl. Timer controls are unusual in that you can instantiate the control class directly. Most other controls requires that you declare a subclass of the base class (in a CTRL file) and then instantiate the new class.

Related Topics

Add Timer Control Dialog

Using a Timer Control

Specifying Time on a Timer Control