Plumtree Tags API  
 

ATag Class

This is the base class that developers will use to write their own custom tags.

In order to implement a Tag, developers need to follow the steps below:
  1. Implement the DisplayTag() abstract method. If you want this tag to display the HTML and tags inside the tag, you must call ProcessTagBody() and return the resulting HTML.
  2. Implement the Create() abstract method to return a new instance of this Tag.
  3. Create exactly one public static final ITagMetaData member variable that provides the name and description of the Tag and initialize it in the static initializer.

    E.G. <pt:thistag/> would need
    public static final ITagMetaData TAG;
    static ThisTag() (or just static in c#)
    {
    TAG = new TagMetaData("thistag", "This tag displays some HTML ...");
    }

    Note that the TagMetaData class automatically converts the tag name to lowercase, which means that all references to the tag in HTML need to use the lowercase name.
  4. Create one public static final RequiredTagAttribute or OptionalTagAttribute member variable for every attribute that this tag supports and initialize them in the static initializer.

    E.G. <pt:thistag pt:firstattribute="foo" pt:secondattribute="bar"/> would need
    public static final RequiredTagAttribute FIRST_ATTRIBUTE;
    public static final OptionalTagAttribute SECOND_ATTRIBUTE;
    static ThisTag() (or just static in c#)
    {
    FIRST_ATTRIBUTE = new RequiredTagAttribute( "firstattribute", "This attribute is used to ...");
    SECOND_ATTRIBUTE = new OptionalTagAttribute( "secondattribute", "This optional attribute is used to ...", AttributeType.STRING, "default value");
    }
The ITagMetaData, RequiredTagAttribute, and OptionalTagAttribute objects are used for programmatic access to tag meta data, as well as to pre-process tag attributes (presence, correct type, and default values). If the required attributes are not correct, an error will be logged and the tag and its children will be skipped and not displayed. An HTML Comment describing the tag and error will be displayed instead.

A description of the valid formats for attributes can be found in the AttributeType class.

Optionally, a Tag developer can also:
  1. Override the DisplaySharedJavascript() method to include javascript once per page, rather than once per tag.
  2. Override the GetTagType() method to show that this tag is a different type of tag; e.g. LOOPING or NO_BODY.
  3. Override the SupportsAccessStyle() method to display this tag in non-standard access styles, such as 508 compliant. If a tag does not use javascript, this method should be overridden to always return true so the tag can be used in 508 and low-bandwidth modes.
  4. Override the ReleaseTag() method to release data stored on the tag. All tags that store custom data as member variables should override this method.
  5. Create a public static final RequiredParentTag member variable to require that this tag be used inside a particular tag and initialize it in the static initializer. If there are multiple RequiredParentTag members, then at least one parent tag must be present in order for the tag to function (but not all parent tags are required to be present).
  6. Create one public static final RequiredChildTag member variable for every tag that is required to be used inside this tag and initialize it in the static initializer.
  7. Create one public static final RelatedChildTag member variable for every tag that is designed to be used inside this tag, but is not required to be used inside this tag. Initialize the member variable in the static initializer.
All public static final metadata objects should be initialized together in a single static initializer so that the order of initialization can be properly controlled.

The ITagMetaData TAG member variable needs to be initialized first since it can be used in other tags (i.e. as a RequiredParentTag) that are referenced by member variables of this tag (i.e. as a RelatedChildTag). This is necessary for tags that have circular references such as a parent / child tag relationship.

The ATag methods are grouped into several different categories of methods. Thread Safety

Each tag instance is guaranteed to be accessed by only a single thread at a time. However, there may be multiple threads accessing different instances of the same tag class at the same time, either from the same user or a different user. This means that any static fields will need to be accessed using synchronized methods. It is a best practice not to use static fields for data storage in tags.

Since there can be multiple instances of the same tag running at the same time, state variables set in shared Scopes (E.G. Scope.SESSION, Scope.PERSISTENT_SESSION, and Scope.APPLICATION) may change values during the execution of a single tag.

For a list of all members of this type, see ATag Members.

System.Object
   com.plumtree.portaluiinfrastructure.tags.helper.ATagInfrastructure
      com.plumtree.portaluiinfrastructure.tags.ATag

public abstract class ATag : ATagInfrastructure

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: com.plumtree.portaluiinfrastructure.tags

Assembly: portaluiinfrastructure (in portaluiinfrastructure.dll)

See Also

ATag Members | com.plumtree.portaluiinfrastructure.tags Namespace | AttributeType | ITagMetaData | TagMetaData | RequiredTagAttribute | OptionalTagAttribute | RequiredParentTag | RequiredChildTag | RelatedChildTag | ITagState