Show TOC

Procedure documentationCreating an OBN Link (Web Dynpro) Locate this document in the navigation structure

 

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

Prerequisites

  • You understand how portal navigation is triggered in Web Dynpro applications, as described in Navigating in the Portal.

  • You add the following imports:

    Syntax Syntax

    1. importcom.sap.portal.obn.service.IOBNMetadata;
      importcom.sap.portal.obn.service.IOBNService;
      importcom.sap.portal.obn.service.OBNFactory;
      
    End of the code.

Procedure

  1. To your view, add a UI element that triggers navigation, such as a button element.

    This graphic is explained in the accompanying text.

  2. Add an event action to the UI element.

    For example, to the onAction event of the button, add an action called OBN.

    This graphic is explained in the accompanying text.

  3. In the action handler method, do the following:

    1. Create an instance of the OBNFactory helper class.

      Syntax Syntax

      1. public voidonActionOBN(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ){
            //@@begin onActionOBN(ServerEvent)
            boolean isPost = false;
        
            IOBNService obnService = (IOBNService) WDPortalUtils
                .getServiceReference(IOBNService.KEY); 
            OBNFactory obnFactory = obnService.getObjectsFactory();
        
      End of the code.

      Note Note

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

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

      Syntax Syntax

      1.     IOBNMetadata obnMetaData = obnFactory
                .createOBNMetadata("myBO","","myOp",
                WDClientUser.getCurrentUser().getSAPUser());
      End of the code.

      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.

      Syntax Syntax

      1. String obnUrl = obnMD.getOBNUrl(false);
      End of the code.
    4. Trigger navigation.

      Syntax Syntax

      1.     try {
                WDPortalNavigation.navigateAbsolute(obnUrl,
                    WDPortalNavigationMode.SHOW_INPLACE,
                    null,
                    null,
                    WDPortalNavigationHistoryMode.NO_HISTORY,
                    null,
                    null,
                    obnMetaData.getOBNUrlParametersString(),
                    null,
                    isPost,
                    true);
                } catch(Exception e) {
                    // Handle exceptions
                }
           //@@end
        }
        
      End of the code.