Show TOC Start of Content Area

Background documentation Getting/Setting Attributes  Locate the document in its SAP Library structure

The following gets the Object isa Template attribute, and its Inheritance meta-attribute:

IAdminBase myAdmin = (IAdminBase)iCtx.lookup(myObject);

IAttributeSet attrSet = (IAttributeSet)
   myAdmin.getImplementation(IAdminBase.ATTRIBUTE_SET);

 

// Display Object is a Template attribute

response.write(attrSet.getAttribute(
    IAttrPcmGeneral.ATTRIBUTE_IS_TEMPLATE)
);

 

// Display Inheritance meta-attribute of Object is a Template attribute

response.write(attrSet.getMetaAttribute(
    IAttrPcmGeneral.ATTRIBUTE_IS_TEMPLATE,
        IAttrPcmGeneral.META_ATTRIBUTE_INHERITANCE));

The following sets the Object isa Template attribute to true:

attrSet.putAttribute(IAttrPcmGeneral.ATTRIBUTE_IS_TEMPLATE,true);

attrSet.save();

If the attribute does not exist, it is created.

Text Attributes

Text attributes are translatable and, therefore, generally require an additional parameter that indicates the locale.

The following attributes require the use of the locale:

     com.sap.portal.pcm.Title

     com.sap.portal.pcm.Description

The following meta-attributes require the use of the locale:

·        plainDescription

·        longDescription

·        category

·        validValueTitle0, validValueTitle1, and so forth.

The following gets the Title text attribute:

response.write (attrSet.getAttribute(
    IAttrPcmGeneral.ATTRIBUTE_TITLE,request.getLocale()));

Attribute Constants

To specify an attribute, use the designated constant for that attribute. The constants for each semantic type are located in a corresponding interface in the com.sap.portal.pcm.attributes package.

For example, the constants for iView attributes are located in the IAttriView interface. The following code checks whether the current iView allows browser caching:

response.write(
   
attrSet.getAttribute(IAttriView.ATTRIBUTE_ALLOW_BROWSER));

 

End of Content Area