Show TOC

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

 

This section describes how to add a layout to a page.

Each page is assigned a default layout, which is used for rendering the page. You can assign other layouts to a page to enable users to personalize the page. Users can then select one of the other layouts assigned to the 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 layout that you want to add to your page.

    Syntax Syntax

    1.     ILayouts layoutSrv = (ILayouts)
              PortalRuntime.getRuntimeResources().getService(ILayouts.KEY);
      
          NewObjectDescriptor layoutToAdd =
              (NewObjectDescriptor) layoutSrv.instantiateDescriptor
                  (CreateMethod.DELTA_LINK,
                      "pcd:portal_content/templates/layouts/narrowWide",
                           request.getUser());
      
    End of the code.
  4. Add the layout descriptor to the page.

    Syntax Syntax

    1. ...
      
          myPage.addLayout(layoutToAdd, "newLayout");
      }       
      catch(NamingException e)
      {
      }
      
    End of the code.

    Note Note

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

    End of the note.