Show TOC

Procedure documentationAdding iViews to a Page Locate this document in the navigation structure

 

This section describes how to add an iView (or page) to a page.

Procedure

  1. Set the parameters for a JNDI lookup in the PCD.

    Syntax Syntax

    1. Hashtable env = new Hashtable();
      
      env.put(Context.INITIAL_CONTEXT_FACTORY,
          IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
      env.put(Context.SECURITY_PRINCIPAL, request.getUser());
      env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);
      
    End of the code.
  2. Perform a lookup of the page to which you want to add an iView.

    Syntax Syntax

    1. InitialContext iCtx = null;
      try
      {
          iCtx = new InitialContext(env);
          IPage myPage =(IPage)iCtx.lookup(
              "pcd:portal_content/Desktop/finance");
      
      ...
      
    End of the code.
  3. Create a descriptor (NewObjectDescriptor object) for the iView or page that you want to add to your page.

    Syntax Syntax

    1.     IiViews iViewSrv = (IiViews)
              PortalRuntime.getRuntimeResources().getService(IiViews.KEY);
      
          NewObjectDescriptor iViewDescriptor =
              (NewObjectDescriptor)iViewSrv.instantiateDescriptor
                  (CreateMethod.DELTA_LINK,
                      "pcd:portal_content/testxml", request.getUser());
      
    End of the code.
  4. Add the iView descriptor to the page.

    Syntax Syntax

    1. myPage.addiView(iViewDescriptor,"testxml");
    End of the code.

    The iView is automatically displayed at the bottom of the left-most column of the layout that is currently being used for the page.

    If you want to place the iView into a particular column of a particular layout, you can specify a layout container into which to add the iView. The following adds the iView into the com.sap.portal.reserved.layout.Cont2 container (second column) of the current layout:

    Syntax Syntax

    1. ...
      
          myPage.addiView(IVtoAdd,"testxml",
              "com.sap.portal.reserved.layout.Cont2");
      }       
      catch(NamingException e)
      {
      }
      
    End of the code.

    com.sap.portal.reserved.layout.Cont2 is the container ID of the second column as defined in a standard layout.

    You can also specify, as integers, the vertical position of the iView within the layout container:

    Syntax Syntax

    1. ...
          myPage.addiView(iView1,"testxml1",
              "com.sap.portal.reserved.layout.Cont2",1);
          myPage.addiView(iView2,"testxml2",
              "com.sap.portal.reserved.layout.Cont2",2);
      ...
      
    End of the code.

    Note Note

    If an iView with the same atomic name exists in the page, an error is thrown.

    End of the note.