Show TOC

Catalog Node AttributesLocate this document in the navigation structure

Use

With the ICatalogNode interface, you can get information about portal objects in order to display them in administration editors or other applications. The interface, for example, is used by the Portal Catalog user interface to display the tree of portal content.

The following are the key methods:

  • getTitle() : Returns the friendly name of the object.

  • getIcon() : Returns a PcmUri object that enables you to get the URL for the image that represents the object's type.

The following retrieves the catalog node attributes for a portal object:

            Hashtable env1 = new Hashtable();
 
env1.put(Context.INITIAL_CONTEXT_FACTORY,
    IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
env1.put(Context.SECURITY_PRINCIPAL, request.getUser());
env1.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_ADMINISTRATION);
 
InitialContext iCtx = null;
 
try {
    iCtx1 = new InitialContext(env1);
    IAdminBase adminBase = (IAdminBase)iCtx.lookup(lookupObject);
 
    // Write type of portal object
    response.write("Object Type: " + adminBase.getObjectType()+"<BR>"); 
      
    // Get ICatalogNode interface
    ICatalogNode cn = (ICatalogNode) adminBase
        .getImplementation(IAdminBase.CATALOG_NODE);
 
    // Write title of portal object
    response.write(cn.getTitle(request.getLocale())+"<BR>");
 
    // Get object for obtaining image URL
    PcmUri pcmUri = cn.getIcon(ObjectState.DEFAULT);
      
} catch (NamingException e) {}
         

Displaying Icons

The PcmUri is a generic object enabling you to derive the URL for an image. It is independent of the user interface technology.

The following code shows how to derive the URL from within a portal (PRT) application:

               String iconURL = "";
 
ICatalogNode cn = (ICatalogNode) adminBase
    .getImplementation(IAdminBase.CATALOG_NODE);
PcmUri pcmUri = cn.getIcon(ObjectState.DEFAULT);
 
switch (pcmUri.getUrlType()) {
 
    case PcmUri.URL_TYPE_APPLICATION_RESOURCE:
        iconURL = request.getWebResourcePath(pcmUri.getApplication())
            + "/" + pcmUri.toString();
        break;
 
    case PcmUri.URL_TYPE_JNDI_URL:
        IPortalComponentURI componentURI = 
            request.createPortalComponentURI();
        componentURI.setContextName(pcmUri.toString());
        iconURL = componentURI.toString();
        break;
 
    case PcmUri.URL_TYPE_ABSOLUTE:
        iconURL = pcmUri.toString();
        break;
}

            

The following code shows how to derive the URL from within a Web Dynpro application:

               String iconURL = "";
 
ICatalogNode cn = (ICatalogNode) adminBase
    .getImplementation(IAdminBase.CATALOG_NODE);
PcmUri pcmUri = cn.getIcon(ObjectState.DEFAULT);
 
switch (pcmUri.getUrlType()) {
 
    case PcmUri.URL_TYPE_APPLICATION_RESOURCE:
        iconURL = WDPortalUtils
            .getPortalWebResourceURL(pcmUri.getApplication())
                + "/" + pcmUri.toString();
        break;
 
    case PcmUri.URL_TYPE_JNDI_URL:
        iconURL = pcmUri.toString();
        break;
 
    case PcmUri.URL_TYPE_ABSOLUTE:
        iconURL = pcmUri.toString();
        break;
}