Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos
In the beginning, administrators created portal objects. They used the administration tools to create iViews, then to create pages and add the iViews to the page. Then they created worksets and roles. Administrators still do it this way, but now there are other tools make portal objects, and to make them more quickly. The most notable tools are:
  • XML Content and Actions (aka, Generic Creator): You can upload an XML script that can automatically create portal objects. This is particularly helpful when you are creating many similar portal objects, and you do not want to make each one individually with the administration tools. It can also be helpful when migrating a system, and you want to create the same objects several times on different systems. The XML Content and Upload tool is described more fully in my blog SP15: XML Content and Actions
  • PCD API: The portal exposes Java objects for some of the standard semantic objects that can be stored in the PCD. You can use the API to create, modify and delete objects. You can add iViews to pages, change layouts and more. APIs are available for the following objects:
    • iViews
    • Pages
    • Layouts
    • Systems
    The PCD API for creating portal objects is explained in this blog.
The API is described in detail in the revised Portal Developer Guide for SAP NetWeaver 2004 SP Stack 18, which will be available on the Help Portal starting August 22 (will also be included for SAP NetWeaver 2004s). See the section Core Development Tasks --> Accessing the PCD. This blog provides the highlights. If you can't wait, the documentation is available from SDN as a PDF file. Either way, this blog discusses the section called Working with Semantic Objects. The key thing to keep in mind is that for some tasks, like adding an iView to a page, you need the Java semantic object. When doing a PCD lookup, make sure to specify the semantic aspect -- that is, set the aspect to the constant PcmConstants.ASPECT_SEMANTICS.

Common Tasks

The method for creating a semantic object is the same for all types of objects. The following shows how to create an iView (the only thing special here is that, because this is an iView, you use the IiViews object to create the descriptor): import com.sap.portal.pcm.iview.IiViews; import java.util.Hashtable; import com.sap.portal.pcm.INewObjectDescriptor; import javax.naming.Context; import com.sap.portal.directory.Constants; import com.sapportals.portal.pcd.gl.IPcdContext; import com.sap.portal.pcm.admin.PcmConstants; import com.sapportals.portal.prt.jndisupport.InitialContext; IiViews iViewSrv = (IiViews)    PortalRuntime.getRuntimeResources().getService(IiViews.KEY); INewObjectDescriptor IVtoCreate = (INewObjectDescriptor)    iViewSrv.instantiateDescriptor(CreateMethod.NEW,       "par:/applications/myProject/components/myComponent",request.getUser()); 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); InitialContext iCtx = null; try {    iCtx = new InitialContext(env);    String folderID = "pcd:portal_content/myFolder";    Context ctx = (Context)iCtx.lookup(folderID);    ctx.bind("myNewHelloIV", IVtoCreate); } catch(NamingException e) {} The key method is instantiateDescriptor(), in which you specify:
  • New or Delta Link: Indicates whether the new object is a copy of or a delta link to an existing object.
  • Template: Indicates on what to base the iView, either an existing PCD object (copy or delta link) or PRT component (new).
You can also lookup objects (and get the corresponding Java object for the specific semantic object) and delete objects. And since all the Java objects described here implement IAttributeSet, you can also set object properties.

iViews

The only special thing you can do with iViews is add related items (dynamic navigation or related item). A link to a related iView is displayed whenever a user navigates to the iView. To add a related item, perform a lookup and get a Java object for the iView, create a descriptor for the related iView, and add it to the iView. try {    iCtx = new InitialContext(env);    IiView myIView =(IiView)iCtx.lookup(iViewId);    INewObjectDescriptor iViewDescriptor =       (INewObjectDescriptor)iViewSrv.instantiateDescriptor          (CreateMethod.DELTA_LINK, "pcd:portal_content/testxml", request.getUser());    myIView.addRelatedItem(iViewDescriptor,"testxml",       RelatedItemType.DYNAMIC_NAVIGATION); } catch(NamingException e) {}

Pages

With pages, you can perform the following tasks:
  • Add and remove iViews:
  • Adding an iView to a page is just like adding a related item to page. The only real difference is that you can also specify the column to which to add the iView.
  • Add or remove layouts:
  • Adding a layout to a page is just like adding an iView to page.
  • Set the default layout:
  • Set the layout that is used to display content to the user. The user can select a different layout if you have assigned additional layouts to the page.

Layouts

The main task with layouts is to add an iView to a page and to put it in a specific column. The one thing you can do with the layout API (and you cannot do with the page API) is to put an iView in the middle of a column, and not just at the end of the column. The Layout API also lets you get information about the containers in the layout.

Systems

With systems, you can perform the following tasks:
  • Get, add and remove aliases for a system
  • Set the default alias for a system
  • Get user mapping for a system
You can also get all aliases or default aliases in the system landscape. For this, you use the helper object ISystems.

More Information

Of course, check out the documentation. You can also check out the PCD Knowledge Center
6 Comments