Show TOC Start of Content Area

Background documentation Subscribing to a Client Event  Locate the document in its SAP Library structure

You can subscribe to client events, and specify a Web Dynpro action to be triggered when the event is fired.

Use the WDPortalEventing.subscribe() method to subscribe to an event, as shown in the following example:

WDPortalEventing.subscribe ("urn:com.sap.tc.webdynpro.test.portal",  
                            
"TestEvent",  
                            wdThis.wdGetTestEventAction()); 

The subscribe() method takes the following string parameters:

      Namespace of the event

      Name of event

      Web Dynpro action to trigger when the event is fired

The combination of the namespace and name must be unique among the displayed iViews.

A subscription to an event is only valid for the current view. Each view that wants to listen for an event must subscribe to it separately.

Creating an Action

To receive information about the event in the Web Dynpro action, define the following string parameters in your action:

      dataObject: Event parameter.

      Namespace: Namespace of the event

      Name: Name of the event

These are the three strings provided in the fire() method, as described in Firing a Client Event.

Note

Adding the namespace and name parameters to the action is useful when you want to reuse the action for several client events and you need to determine which event was fired.

Unsubscribing to a Client Event

Use the WDPortalEventing.unsubscribe() method to unsubscribe to an event, as shown in the following example:

WDPortalEventing.unsubscribe("urn:com.sap.tc.webdynpro.test.portal",
                             
"TestEvent",  
                             wdThis.wdGetTestEventAction()); 

Make sure to unsubscribe to the event from every view that needs to be unsubscribed.

 

End of Content Area