Show TOC

Procedure documentationCreating Objects Locate this document in the navigation structure

 

This section describes how to create a semantic object in the PCD by creating a descriptor for the new object and binding it to a folder context.

A new object can be based on an existing PCD object (either as a copy or a delta link) or on an application deployed to the J2EE server.

Procedure

  1. Retrieve an instance of the helper object for the type of semantic object that you want to create, such as, IiViews for an iView, ISystems for a system, and so forth.

    Syntax Syntax

    1. IiViews iViewSrv = (IiViews)
          PortalRuntime.getRuntimeResources().getService(IiViews.KEY);
    End of the code.
  2. Create a descriptor for the new object that you want to create.

    Syntax Syntax

    1. NewObjectDescriptor IVtoCreate = (NewObjectDescriptor)
          iViewSrv.instantiateDescriptor(CreateMethod.NEW,
              "gpar:/applications/myProject/components/myComponent",
                  request.getUser());
    End of the code.

    instantiateDescriptor() takes the following parameters:

    • New or Delta Link: Indicates whether the new object is a copy of or a delta link to an existing object. Use constants from the CreateMethod class.

    • PCD Object or Application: Indicates the existing PCD object or portal application on which to base the new object. The format can be one of the following:

      • PCD name, such as pcd:portal_content/myFolder/myObject Information on defining a namespace prefix for the atomic name of a PCD object: How Are Portal Objects Named and Identified?

      • Portal Component name, in the following format:

        gpar:/myApp/myComp

        where myApp is the name of an application and myComp is the name of a component in myApp.

      If you specify a PCD name, the first parameter can be either NEW or DELTA_LINK. When you specify NEW, a copy of the PCD object is instantiated.

      If you specify an application, the first parameter must be NEW.

    • Current User: An IUser object for the user making the JNDI call.

  3. 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.
  4. Perform a lookup of the folder in which you want to create the new object.

    Syntax Syntax

    1. InitialContext iCtx = null;
      try
      {
          iCtx = new InitialContext(env);
      
          String folderID = "pcd:portal_content/myFolder";
          Context ctx = (Context)iCtx.lookup(folderID); 
      
      ...
      
    End of the code.
  5. Create the object by binding the descriptor to the folder context.

    In this example, the bind method creates a new context, named myNewHelloIV, for the descriptor IVtoCreate, under the folder context.

    Syntax Syntax

    1. ...
      
          ctx.bind("myNewHelloIV", IVtoCreate); 
      
      }       
      catch(NamingException e)
      {
      }
      
    End of the code.