Strategy ONE

Overview of MicroStrategy Custom Tags

MicroStrategy Web includes a rich set of custom tags, provided with the application, that can be used to dynamically generate the HTML output sent to the Web client. These custom tags can be used in JSP and ASP.NET files to call MicroStrategy functionality without the need to write or compile code. Examples of MicroStrategy custom tags include:

  • Table-specific tags that dynamically size tables. (<dynTable> and <dynTableCell>

  • The <beanValue> tag that displays a specific property value of an object, a useful feature for building URLs. 

  • The <connectionValue> tag that returns information about properties related to a given connection, such as the name of the user currently connected or the names and aliases of currently-connected projects. 

  • Tags for including conditional logic, such as "If a bean is of a specific type, then output this HTML." These tags are useful for scenarios such as, "If a report is a specific report, then display this additional panel of information." (<ifBeanValue>, <ifConnectionValue>, etc.) 

  • Tags to assist in building links based on shortcuts. (<shortcutElement>, <shortcutOptions>, <shortcutProperty> and <shortcutSeparator>

  • Tags to dynamically build hyperlinks based on the event that you want the hyperlink to accomplish. (<urlEvent>, <eventArgument>

  • The <javascript> tag that generates javascript code.

    The <javascript> node is a child of a <page> node in the Page Configuration file. It is used in conjunction with the <web:javascript> tag in either a page template file, such as mstrWeb, or a page section file, such as Project_Content (JSP or ASP.NET), to insert JavaScript code into the HTML output. In a page template or page-section file, you add a <web:javascript> tag and associate it with output defined in a <javascript> node. You create the association by setting the eventName attribute in the <web:javascript> tag to the same value as the event attribute in the <javascript> node.

    There is a special case for the  <web:javascript> tag where it is not used with an explicitly defined <javascript> node. When MicroStrategy Web encounters a <web:javascript type="domain"/> tag, it looks in microstrategy.xml for a jsDocumentDomain context parameter. If it finds one, it uses the value of this parameter to generate a piece of javascript code that sets the domain property, as shown below:

     

        <script language="javascript">document.domain="value of jsDocumentDomain context parameter"</script>

     

    In order to generate this javascript, you must set the jsDocumentDomain context parameter in microstrategy.xml, . The code sample below illustrates how to set the domain to "microstrategy.com".

     

       <context-param>

          <param-name>jsDocumentDomain</param-name>

          <param-value>microstrategy.com</param-value>

       </context-param>

     

    In this case, the javascript code generated by a  <web:javascript type="domain"/> tag would look as follows:

     

        <script language="javascript">document.domain="microstrategy.com"</script>

     

    This feature is required for portlet-to-portlet messaging.

MicroStrategy custom tags are used in JSP or ASP.NET files to change the HTML output directly . Using custom tags simplifies and minimizes the amount of code you need to write because these tags provide quick and easy access to a library of sophisticated code that has already been written for you.

Click here to access a list of available MicroStrategy custom tags.

MicroStrategy custom tags are cross-platform and provide identical results in .NET and J2EE environments. However, while the results are the same, there are some minor differences "under the covers". The HTML output generated by JSP files relies on Custom Tag technology from Sun Microsystems, while the HTML output generated by ASP files relies on Web Control technology from Microsoft and uses a .NET bridge to access the underlying Java tag implementation.

In general, custom tags have the syntax shown below:

<prefix:tag attribute1="value" ...attributeN="value" />

MicroStrategy custom tags, however, always use web as the prefix:

<web:tag attribute1="value" ...attributeN="value" />

Using MicroStrategy custom tags in a J2EE environment

In a J2EE environment, the classes that define the MicroStrategy custom tags, together with the tag handler classes that implement them, are located in com.microstrategy.web.app.taglibs. MicroStrategy custom tags used in JSP files directly access the classes that define and implement them.

At the beginning of a JSP file that uses MicroStrategy custom tags, the tag prefix ('prefix=') is declared to be 'web', which, as we mentioned earlier, is the prefix for MicroStrategy custom tags.

<%@ taglib uri="/webUtilTL.tld"prefix="web"%>>

To see a sample JSP file (About_Content.jsp) that uses MicroStrategy custom tags, Closedclick here.

<%

  /*

   * About_Content.jsp

   * Copyright 2001 MicroStrategy Incorporated. All rights reserved.

   */

%>

<%@ page errorPage="Error_Content.jsp" %>

<%@ page contentType="text/html; charset=UTF-8"%>

<%@ taglib uri="/webUtilTL.tld"prefix="web"%>

...

<BR /><BR />

<SPAN Style="font-size: 1.3333em">

    <SPAN CLASS=highlighted>JSP version:</SPAN>&nbsp;<mstrversion>8.0.300.390</mstrversion><BR /><BR />

    <SPAN CLASS=highlighted><web:descriptorkey="mstrWeb.792" desc="XML API version:" /></SPAN>&nbsp;<web:connectionValueproperty="xmlAPIVersion"/><BR /><BR />

    <SPAN CLASS=highlighted>Java Virtual Machine:</SPAN>&nbsp;(<web:connectionValue property="JVMVendor"/>&nbsp;<web:connectionValueproperty="JVMVersion"/>)<BR /><BR />

<%--

 If there is a session and the server versio can be accessed,

 display the Intelligent Server version number.

--%>

    <web:ifConnectionValueproperty="serverVersion">

        <web:then>

            <SPAN CLASS=highlighted><web:descriptorkey="mstrWeb.795" desc="Server version:" /></SPAN>&nbsp;<web:connectionValueproperty="serverVersion"/><BR /><BR />

        </web:then>

    </web:ifConnectionValue>

    <SPAN CLASS=highlighted><web:descriptorkey="mstrWeb.793" desc="Browser version:" /></SPAN>&nbsp;<%=browserVersion%><BR />

</SPAN>

<%--

 This tag displays all the cookies currently defined on the

 client's browser by the application.

--%>

<web:displayCookies/>

Using MicroStrategy custom tags in a .NET environment

In a .NET environment, the custom tags are distributed in a tag library, called mstrTagLib.vb, which is stored in the WEB ASPx folder of the MicroStrategy installation directory. This tag library defines a set of custom tags and the tag handlers that implement them. The tag handler, or helper classes, for the custom tags are actually Java classes, which are located in com.microstrategy.web.app.taglibs. Each ASP tag helper class includes the following:

  • a series of methods to set properties. (This can include setting properties on a parent node if the tag is a nested child.) 

  • a constructor to get the instance of the corresponding Java tag handler class. 

  • a render method that lets you bring the HTML content that is generated back across the bridge (that is, the result of executing the code in the Java tag handler class)

The helper classes defined in mstrTagLib.vb have a bridge to the underlying Java tag handler classes. As a result, the properties that you set in ASP.NET helper classes are set automatically in the corresponding JSP tag helper classes.

At the beginning of an ASP.NET file that uses MicroStrategy custom tags, the tag prefix ('TagPrefix=') is declared to be 'web', which is the prefix for MicroStrategy custom tags.

<%@ RegisterTagPrefix="web"Namespace="MicroStrategy.Tags" %>

To see a sample ASP.NET file (About_Content.aspx) that uses MicroStrategy custom tags, Closedclick here.

<%@ Control Language="vb" AutoEventWireUp="false" Codebehind="About_Content.ascx.vb" Inherits="MicroStrategy.About_Content"%>

<%@ Register TagPrefix="web" Namespace="MicroStrategy.Tags" %>

...

<BR /><BR />

<SPAN Style="font-size: 1.3333em">

    <SPAN CLASS=highlighted>ASP.Net version:</SPAN>&nbsp;<mstrversion>8.0.300.391</mstrversion><BR /><BR />

    <SPAN CLASS=highlighted><web:descriptorrunat="server" key="mstrWeb.792" desc="XML API version:" /></SPAN>&nbsp;<web:connectionValuerunat="server" mproperty="xmlAPIVersion"/><BR /><BR />

    <SPAN CLASS=highlighted>Java Virtual Machine:</SPAN>&nbsp;(<web:connectionValuerunat="server" mproperty="JVMVendor"/>&nbsp;<web:connectionValuerunat="server" mproperty="JVMVersion"/>)<BR /><BR />

<%--

 If there is a session and the server versio can be accessed,

 display the Intelligent Server version number.

--%>

    <web:ifConnectionValuerunat="server" mproperty="serverVersion">

        <web:mthenrunat="server">

            <SPAN CLASS=highlighted><web:descriptorrunat="server" key="mstrWeb.795" desc="Server version:" /></SPAN>&nbsp;<web:connectionValuerunat="server" mproperty="serverVersion"/><BR /><BR />

        </web:mthen>

    </web:ifConnectionValue>

    <SPAN CLASS=highlighted><web:descriptorrunat="server" key="mstrWeb.793" desc="Browser version:" /></SPAN>&nbsp;<web:DisplayBrowserSettingsrunat="server" /><BR />

</SPAN>

<%--

 This tag displays all the cookies currently defined on the

 client's browser by the application.

--%>

<web:displayCookiesrunat="server"/>

There are certain MicroStrategy custom tags that provide the same functionality but differ in name when used in JSP and ASP.NET files. The tag names differ because of a conflict with reserved names used by ASP.NET. The following tags have different names in the two environments:

Custom tag used in JSP files Custom tag used in ASP.NET files

else

melse

enum

menum

string

mstring

then

mthen

See also