Events and Event Arguments
You can define events for a component controller to allow cross-controller communication. These events can then be triggered using the predefined method FIRE_<MY_EVENT>_EVT. Once the event is triggered, the corresponding event handler is automatically called in another controller by the runtime.
A usage of the component controller must be entered in the current controller to handle an event of a component controller. (The usage of the component controller within a view controller is automatically created.)
Cross-Component Events
You can use one or more events of the component controller and use them as cross-component events. Check the Interface checkbox of the Events tab of the component controller in the table. The corresponding event is passed to the component interface and can be accessed by an event handler of another component (see Cross-Component Programming).
Parameter of Events
Events can pass mandatory or optional parameters. You can enter these parameters on the Events tab of the component controller and specify the type. When you then create an event handler in a used controller and assign an event of the component controller to it, the corresponding parameters are automatically added to the signature of the event handler method.
Component Controller
An event is triggered in a method of the component controller and the created parameter is passed.
Events tab
|
Event MY_EVENT Parameter MY_PARAMETER type WDY_BOOLEAN |
Methods tab:
MY_CONTROLLER_METHOD
|
method MY_COMP_CONTROLLER_METHOD . WD_THIS->FIRE_MY_EVENT_EV( MY_PARAMETER ='X'). endmethod. |
View Controller
An event handler is created in a view controller and assigned to the event MY_EVENT. The response of the event handler is according to parameter MY_PARAMETER.
Methods tab
|
Method Method Type Event Controller MY_EVENT_HANDLER Event handler MY_EVENT Component-Controller |
MY_EVENT_HANDLER
|
Parameter Declaration Type Reference Type WDEVENT Importing CL_WD_CUSTOM_EVENT MY_PARAMETERImporting WDY_BOOLEAN |
|
method MY_EVENT_HANDLER . . . . endmethod. |
Additional Concepts: Passing Parameters Using an Event Object
Each event handler method is automatically known to parameter WDEVENT of the type CL_WD_CUSTOM_EVENT. The class interface CL_WD_CUSTOM_EVENT contains the attribute PARAMETERS of the type WD_EVENT_PARAMETER and several methods to read this parameter.
Instead of statically specifying a parameter for an event and automatically add this parameter to the signature of the event handler method of the event handler, you can also dynamically specify the parameter using the event object.
This means that if the parameter is not to be statically specified at design time, it can be read from the event object of the event handler method. For more information, see Dynamically Working with Parameter Mappings in the third part of the programming manual.