Show TOC

Procedure documentationGetting or Setting Attributes of Semantic Objects Locate this document in the navigation structure

 

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

    Syntax Syntax

    1. response.write(obj.getAttribute("attribute"));
      
      response.write(obj.getMetaAttribute("attribute", "meta-attribute"));
      
    End of the code.

    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.

    Syntax Syntax

    1. response.write (obj.getAttribute ("attribute", request.getLocale() ) );
    End of the code.
  • Setting Attributes

    Syntax Syntax

    1. obj.putAttribute("attribute","value");
    2. obj.save();
    End of the code.
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:

Syntax Syntax

  1. response.write(
         obj.getAttribute(IAttriView.ATTRIBUTE_ALLOW_BROWSER));
End of the code.