Strategy ONE

Anchor Tag

The AnchorTag interface is used to create each link exposed in MicroStrategy Web products. It represents an HTML anchor tag, <a>, and provides support to set basic anchor tag attributes, such as “target” and “href”, as well as attributes to execute JavaScript on certain JavaScript actions, such as “onclick” or “onchange”. The AnchorTag interface also has an associated WebEvent, which is the structure used by MicroStrategy Web products to distinguish every possible user action.

The AnchorTag interface defines a set of methods that allow you to get and set:

  • the event associated with the anchor tag  

  • the event information that should be included in the anchor tag  

  • whether to treat the event as a dynamic page update  

  • the hash value that should be appended at the end of the "href" attribute

EventManager provides a utility method, called generateAnchor(), which returns an AnchorTag initialized with information about the event that is passed into it. The AbstractAppTransform class provides a helper generateAnchor() method that maps to the generateAnchor() method of the EventManager. Since all transforms used in MicroStrategy Web products extend the AbstractAppTransform class, all transforms can create an AnchorTag using this method. Transforms simply call the generateAnchor() method when they need to create a new link in the application and pass into it the specific event that should be used to generate the new link.

For example, FolderViewTransform uses AnchorTag instances generated by the generateAnchor() method to create links on the Folder Browsing page. For each link on the page, this transform passes a different event into the method, depending on what the link being created is supposed to do. The code snippet shown below illustrates how FolderViewTransform creates two AnchorTags on the Folder Browsing page— one for the Edit link and one for the Subscribe link.

Copy
//Get edit event
WebEvent eventEdit = getEditEvent(object);
//Generate anchor for the edit event
AnchorTag  anchor = generateAnchor(eventEdit);
anchor.render(out);
 
//Get subscription event
WebEvent subsEvent = getSubscriptionsEvent(object);
//Generate anchor for the subscriptions event
AnchorTag  anchor = generateAnchor(subsEvent);
anchor.render(out);

You can customize the link by extending a transform and overriding the generateAnchor() method in the transform and changing the returned AnchorTag. You can perform the following modifications to the AnchorTag, and thus to the links generated by that transform:

  • add extra parameters to the anchor tag.  

  • set the value of a basic attribute, such as the target page, in the anchor tag.  

  • set the value of an attribute, such as "onclick" or "onmouseover", to execute JavaScript when the corrresponding JavaScript action is triggered.

To add parameters to an anchor tag, you use the Parameter Builder Infrastructure.

See also