Entering content frame

Function documentation Subscribing to a Portal Event Locate the document in its SAP Library structure

Use

The following code shows the signature of the subscribe method:

WDPortalEventing.subscribe(java.lang.String nameSpace, java.lang.String event, IWDAction action);

for example

WDPortalEventing.subscribe (“urn:com.sap.tc.webdynpro.test.portal”,

    “TestEvent”,

    wdThis.wdGetTestEventAction());

You have to define the event’s name and its namespace. The combination of these two names must be unique.

The third parameter is the Web Dynpro action, which should be mapped to the portal event. The action event handler is called if the Web Dynpro application receives the specified portal event on the client side. The mapping between a portal event and a Web Dynpro action is done automatically and it is completely transparent for the Web Dynpro application developer.

You can reuse a Web Dynpro action for several portal events. If you want to receive the portal event’s data you have to define the following parameters for your Web Dynpro action:

·        dataObject
The
dataObject parameter contains the portal event parameter.

·        nameSpace
The
namespace parameter contains the portal event’s namespace.

·        name
The name parameter contains the portal event’s name.

It is useful to add the nameSpace and nameparameters to the Web Dynpro action if the action is reused for several portal events because you can use this information to differentiate between the portal events.

Note: In the current version a portal event subscription is valid for a Web Dynpro view. Therefore you should add the required Java coding, for example in the wdDoInit() method of the generated view class. If you navigate between different views, you have to subscribe to every view for the portal event required.

Unsubscribe from a portal event

Unsubscribing from a portal event is very similar to subscribing. The following code shows the signature of the unsubscribemethod:

WDPortalEventing.unsubscribe(java.lang.String nameSpace, java.lang.String event, IWDAction action);

for example

WDPortalEventing.unsubscribe (“urn:com.sap.tc.webdynpro.test.portal”,

    “TestEvent”,

    wdThis.wdGetTestEventAction());

Note: You must unsubscribe every Web Dynpro view, because subscription and unsubscription is valid only for the current view.

Raise a portal event

The following example shows how to raise a portal event. The signature is:

WDPortalEventing.fire(java.lang.String nameSpace, java.lang.String event, java.lang.String parameter);

for example

WDPortalEventing.fire (“urn:com.sap.tc.webdynpro.test.portal”,

     “TestEvent”,

    “AParameter”);

You can fire a portal event anywhere in your Web Dynpro application. The event is sent to the client  with the next response. You can also raise more than one portal event in a request-response cycle. Typically, you will fire a portal event in a Web Dynpro action event handler (for example, as a response to pressing a button).

The following step-by-step example shows how to carry out portal eventing within two simple Web Dynpro example applications.

 

  

  

Leaving content frame