Start of Content Area

Background documentation Registering and Handling an Event  Locate the document in its SAP Library structure

Registration for a Portal Event

To register your Web Dynpro application for a portal event, you have the method SUBSCRIE_EVENT available in the interface IF_WD_PORTAL_INTEGRATION.

Note To delete your registration for the portal event, use the method UNSUBSCRIBE_EVENT in the portal manager.

Note Registration or deletion of registration must be performed individually for each view in the respective method WDDOINIT.

 

Generate yourself a suitable template using the Web Dynpro Code Wizard. You can then fill this with values.

  

method WDDOINIT .

 

  data: L_API_COMPONENT  type ref to IF_WD_COMPONENT,

        L_PORTAL_MANAGER type ref to IF_WD_PORTAL_INTEGRATION,

        VIEW type ref to IF_WD_VIEW_CONTROLLER.

 

  L_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).

  L_PORTAL_MANAGER = L_API_COMPONENT->GET_PORTAL_MANAGER( ).

 

  VIEW ?= WD_THIS->WD_GET_API( ).

 

  L_PORTAL_MANAGER->SUBSCRIBE_EVENT(

        PORTAL_EVENT_NAMESPACE =

        'my_namespace_for_Web_Dynpro_documentation'

        PORTAL_EVENT_NAME      = 'showCustomer'

        VIEW                   = VIEW

        ACTION                 = 'RECIEVE_CUSTOMER_ID' ).

 

endmethod.

Enter the namespace and the name of the event. The combination of namespace and event name must be unique. In addition, enter the name of the action that is to be triggered if exactly this portal event is to be received. The corresponding action handler is then called automatically.

Caution The action, in this case RECEIVE_CUSTOMER_ID, is not created automatically. Therefore, create the action explicitly on the tab page Actions in the view.

 

Handling a Portal Event

The parameters of a portal event are passed to the action parameter WDEVENT using its method GET_STRING. With the help of the optional parameter PORTAL_EVENT_PARAMETER, you can have application-dependent information passed to the handler method. In the following example, this is the ID of a particular customer whose value is passed to the SHOWCUSTOMER method of the component controller called afterwards.

 

method ONACTIONRECIEVE_CUSTOMER_ID .

 

  data: EVT_NAME type STRING,

        CUST_ID type SCUSTOM-ID.

 

  EVT_NAME = WDEVENT->GET_STRING( NAME = 'PORTAL_EVENT_NAME' ).

 

  if EVT_NAME = 'showCustomer'.

    CUST_ID = WDEVENT->GET_STRING( NAME = 'PORTAL_EVENT_PARAMETER' ).

    WD_COMP_CONTROLLER->SHOWCUSTOMER( CUSTOMER_ID = CUST_ID ).

  endif.

 

endmethod.

 

 

Example

You can find examples in the Web Dynpro applications in the system:

·        WDR_TEST_PORTAL_EVENT_REC

Receive portal event

·        WDR_TEST_PORTAL_EVENT_REC2

This application also serves as a test application. You can enter the name of an event from your own application in order to test the event separately.

 

 

End of Content Area