Friday, July 25, 2008

Showing posts with label Dynamic Programming. Show all posts Dynamically Registering an Event Handler to an Event Web Dynpro ABAP Dynamic Programming

Components you use within another component can have events. An event of an interface definition is triggered in the component in which the interface definition is implemented.

An event handler of the using component can register onto such an event. If the usage of a component has been created dynamically, then also the registration of the using component onto an event of the used component or the implemented interface must be created dynamically. The code fragment below shows an example of how to implement a dynamic registration.

method MY_CONTROLLER_METHOD .

data: L_COMPONENT_API type ref to IF_WD_COMPONENT,

L_COMPONENT_USAGE type ref to IF_WD_COMPONENT_USAGE.

L_COMPONENT_API = WD_COMP_CONTROLLER->WD_GET_API( ).

L_COMPONENT_USAGE->ADD_EVENT_HANDLER(

listener = L_COMPONENT_API

handler_name =

controller_name = 'INTERFACECONTROLLER'

event_name = ).

.

.

endmethod.

The method ADD_EVENT_HANDLER ( ) is called at the object of the component usage L_COMPONENT_USAGE. The attribute controller_name describes the controller in which the event is defined: If, as described here, the event is defined in a used component, then it can only be the interface controller of this component.

The method you want to implement in the registration must be called in the Phase Model of the Web Dynpro framework at a point in time before the call of the method that triggers the event.

No comments:

Archive