Show TOC

Getting or Setting Attributes of Semantic ObjectsLocate this document in the navigation structure

Use

This section describes how to get and set object attributes using the Java semantic interfaces.

More information about getting or setting attributes using administration interfaces: Getting or Setting Attributes of Administration Objects

More information about getting or setting attributes using PCD interfaces: Contexts and Attributes

Procedure

In the following examples, obj is a semantic Java object.

More information about retrieving an object: Looking Up Objects

  • Getting Attributes and Meta-Attributes

                      response.write(obj.getAttribute("attribute"));
     
    response.write(obj.getMetaAttribute("attribute", "meta-attribute"));
    
                   

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

                      response.write (obj.getAttribute ("attribute", request.getLocale() ) );
                   
  • Setting Attributes

                      obj.putAttribute("attribute","value");
                      obj.save();
                   

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(
     obj.getAttribute(IAttriView.ATTRIBUTE_ALLOW_BROWSER));