Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

event

Former Member
0 Kudos

when a static event is triggered then can an instance method can handle it and register at runtime so that it gets executed when that particular event triggers.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Dear Sandeep,

Static events can be triggered by any method of the class but static methods may only trigger static events.

The SET HANDLER statement links a list of handler methods to corresponding event triggers - either instance events or static events. The syntax and effect of the SET HANDLER statement differs according to the event type.

With instance events, you must use the FOR addition to specify the triggering instance for which you want to register the trigger. You can either specify a single triggering instance using a reference variable <ref>, or specify the handler for all instances using the statement SET HANDLER … FOR ALL INSTANCES.

FOR ALL INSTANCES also applies to triggering instances that do not yet exist when the registration is made.

You cannot use the FOR addition with static events. Instead, the registrtation applies automatically to the entire class or all classes that implement an interface with a static event. The SET HANDLER statement also has an addition ACTIVATION, which allows you to register and deregister handlers automatically.

Regards

Kesava

2 REPLIES 2

Former Member
0 Kudos

Dear Sandeep,

Static events can be triggered by any method of the class but static methods may only trigger static events.

The SET HANDLER statement links a list of handler methods to corresponding event triggers - either instance events or static events. The syntax and effect of the SET HANDLER statement differs according to the event type.

With instance events, you must use the FOR addition to specify the triggering instance for which you want to register the trigger. You can either specify a single triggering instance using a reference variable <ref>, or specify the handler for all instances using the statement SET HANDLER … FOR ALL INSTANCES.

FOR ALL INSTANCES also applies to triggering instances that do not yet exist when the registration is made.

You cannot use the FOR addition with static events. Instead, the registrtation applies automatically to the entire class or all classes that implement an interface with a static event. The SET HANDLER statement also has an addition ACTIVATION, which allows you to register and deregister handlers automatically.

Regards

Kesava

Former Member
0 Kudos

Hi Sandeep,

Yes. Instance method can handle the static event and register for that.

As a matter of fact there is no restriction as per handling of the event.

See the handling is done at run time so we cant restrict the same at design time.

Got the point.

What we can restrict at design time is triggering the event, I mean RAISE EVENT. Instance methods can trigger any events.

Static methods can trigger only static events.

Gr8 enthusisam. Keep going . Get back if u have further doubts.

Reward points if useful,

Aleem.