Show TOC Start of Content Area

Procedure documentation Creating Objects  Locate the document in its SAP Library structure

This section describes how to create a semantic object in the PCD by first 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.

IiViews iViewSrv = (IiViews)
    PortalRuntime.getRuntimeResources().getService(IiViews.KEY);

       2.      Create a descriptor for the new object that you want to create.

INewObjectDescriptor IVtoCreate = (INewObjectDescriptor)
    iViewSrv.instantiateDescriptor(CreateMethod.NEW,
       
"gpar:/applications/myProject/components/myComponent",
            request.getUser());

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

       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. 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.

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);

       4.      Perform a lookup of the folder in which you want to create the new object.

InitialContext iCtx = null;

try

{

    iCtx = new InitialContext(env);

 

    String folderID = "pcd:portal_content/myFolder";

    Context ctx = (Context)iCtx.lookup(folderID);

 

...

 

       5.      Create the object by binding the descriptor for the new object to the folder context.

...

 

    ctx.bind("myNewHelloIV", IVtoCreate);

 

}      

catch(NamingException e)

{

}

...

 

End of Content Area