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", |
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.
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.
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.
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", |
Make sure to unsubscribe to the event from every view that needs to be unsubscribed.