Show TOC Start of Content Area

Procedure documentation Creating an OBN Link (Portal Runtime)  Locate the document in its SAP Library structure

This section describes how to create an OBN link in a portal application.

Note

To execute this code, you also need a reference to the tc/ep/navigation/api DC.

Prerequisites

      You understand standard portal navigation, as described in Navigating in the Portal.

      You understand the portal’s client-side eventing mechanism, as described in Communicating with Other iViews.

      You add the following imports:

importjava.util.Iterator;

importcom.sap.portal.obn.service.IOBNMetadata;

importcom.sap.portal.obn.service.IOBNParameterData;

importcom.sap.portal.obn.service.IOBNService;

importcom.sap.portal.obn.service.OBNFactory;

importcom.sapportals.portal.navigation.IClientNavigationGenerator;

importcom.sapportals.portal.navigation.INavigationConstants;

importcom.sapportals.portal.navigation.INavigationLink;

importcom.sapportals.portal.navigation.INavigationService;

importcom.sapportals.portal.navigation.NavigationParameterData;

importcom.sapportals.portal.navigation.NavigationParameters;

importcom.sapportals.portal.navigation.NavigationSettings;

importcom.sapportals.portal.prt.component.IPortalComponentRequest;

importcom.sapportals.portal.prt.runtime.PortalRuntime;

Procedure

...

       1.      Create an instance of the OBNFactory helper class.

IOBNService obnService = (IOBNService)PortalRuntime
    .getRuntimeResources().getService(IOBNService.
KEY);

OBNFactory obnFactory = obnService.getObjectsFactory();

Note

You can also obtain an OBNFactory instance by using the static method OBNFactory.getInstance().

       2.      Create an IOBNMetadata object for the business object and operation to which you want to navigate.

IOBNMetadata obnMD = obnFactory
    .createOBNMetadata(
"myBO",null,"myOp",request.getUser());

There are many variations on creating an IOBNMetadata object. For example, you can instead specify only a business object, and the portal will navigate to the highest-priority operation for which the user has a valid implementation.

       3.      Get the OBN URL for the navigation.

String obnUrl = obnMD.getOBNUrl(false);

       4.      Collect all the OBN parameters so you can pass them in the navigation call.

NavigationParameters is a standard navigation object for collecting parameters to be passed to the target iView.

NavigationParameters navParams = new NavigationParameters();

Iterator obnMDParamsIter = obnMD.getParametersNames(true).iterator();

 

while (obnMDParamsIter.hasNext()) {

    String paramName = (String)obnMDParamsIter.next();

    IOBNParameterData obnParamData = obnMD.getParameter(paramName);

    navParams.addNavigationParameter(
        paramName,
newNavigationParameterData(
            obnParamData.getValue(), obnParamData.isPost()));

}

       5.      Create the JavaScript code for navigating.

// Get instance of helper service

IClientNavigationGenerator navGenerator = (IClientNavigationGenerator)
    PortalRuntime.getRuntimeResources().getService(INavigationService.
KEY);

 

// Create navigation settings object

NavigationSettings navSettings = new NavigationSettings();

navSettings.setMode(INavigationConstants.SHOW_INPLACE);

 

// Create navigation link object

INavigationLink link = navGenerator
    .createAbsoluteNavigateClientCall(obnUrl , navParams, navSettings);

       6.      Create a clickable UI element that triggers the navigation, and trigger the JavaScript code. The following creates a button that, when clicked, triggers the OBN navigation.

response.write("<input value=\"MyOp\" type=button onclick=\"" +
    link.getOnClick() +
"\"><br>");

End of Content Area