Show TOC

Setting a Dynamic Runtime URLLocate this document in the navigation structure

Use

A typical URL iView is defined with a static source URL from which to render its content. Alternatively, you can specify that the source URL of a URL iView is set dynamically at runtime by the user, for example, when you have many Web pages that you want to display in the portal but you do not want to create and maintain a URL iView for each one. You can create a single URL iView and pass the URL as a parameter in the request.

The process of setting the URL at runtime involves the following design time tasks:

  1. Content administrator: Creates a URL iView, and modifies the iView's properties to specify that the URL is set dynamically at runtime.

  2. Developer: Creates an application that contains a link to the URL iView. The application includes a parameter whose value is the target URL of the URL iView created by the content administrator.

  3. Content administrator:

    1. Creates an application-based iView based on the deployed application.

    2. Assigns the application-based iView to the page(s) or role(s) of users.

    3. Ensures that users have end-user permission for both the application-based iView and the URL iView.

Procedure

Step 1: Content Administrator Creates the URL iView and Configures the Forced URL Properties

  1. Create the URL iView (see Using the URL iView Wizard ).

    Note

    The source URL you set for the iView has less relevance as it will be redirected to a different source at runtime. However, setting the Source URL is mandatory. We recommend you enter a fall-back URL that can be used by the iView in case the forced URL is not rendered at runtime due to an unexpected error.

  2. Using the Property Editor, modify the following properties in the URL iView:

    • Set the Forced URL - Enabled property to Yes .

      The default is No .

    • In the Forced URL - Parameter Name property, enter the name of the URL parameter to be used to retrieve the iView's URL in the application (see below).

      The default is forcedURL .

  3. Save the changes.

Step 2: Developer: Creates an Application that Redirects the Runtime URLs and References the URL iView

  1. Create an application that contains a link to the URL iView. The application must include a parameter whose value is the target URL of the URL iView created by the content administrator.

    When creating a link to the URL iView from another iView, add a URL parameter, as follows:

    • Parameter Name: The value of the URL iView's Forced URL - Parameter Name property.

    • Parameter Value: The URL of the Web page to be displayed in the URL iView.

      Note that if this URL contains URL parameters, then the entire URL, including the URL parameters, must be URL encoded, as in the following example:

      String myURL = URLEncoder
                      .encode("http://www.search.com/search?hl=en&q=Baseball");
                              

    The following code sample shows an application that calls a URL iView located in the PCD at portal_content/test/SAPiView . The iView's URL is set to www.sap.com with forced URL enabled and the forced URL parameter set to forcedURL . An EPCM event, called doNavigate , is used to link to the URL iView.

    import com.sapportals.portal.prt.component.*;
     
    public class redirect_URL_2 extends AbstractPortalComponent
    {
            public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
            {
                    /* In the following instance, the forcedURL parameter is
                    passed to the linked URL iView, but will open it with
                    the SDN URL.
             response.write("<A HREF=\"SAP Developer Network (SDN) Website\"  onclick=\"return EPCM.doNavigate('ROLES://" +
                            "portal_content/test/SAPiView" +
                            "?forcedURL=http://www.sdn.sap.com')\">SAP Developer Network (SDN) Website</A>");
             response.write("<br>");
     
                    /* In the following instance, no additional parameters are
                    passed. It uses the original URL of the URL iView
                    (www.sap.com).
     
             response.write("<A HREF=\"SAP.com Website\"  onclick=\"return EPCM.doNavigate('ROLES://" +
                            "portal_content/test/SAPiView')" +
                            "\">SAP.com Website</A>");
            }
    }
                      
  2. Deploy the application to the portal once it has been created.

Step 3: Content Administrator Creates an iView for the Deployed Application and Assigns it to Users with Necessary Permissions

  1. Create a standard iView for the deployed application. In the iView Wizard, choose Portal component as the source type.

  2. Assign the iView to users by adding it to a portal page or directly to a portal role.

    Note

    The URL iView created earlier does not need to be assigned to any portal page or role.

  3. Ensure that both the application-based iView and the URL iView have the end-user permission enabled for the relevant portal users.