Microstrategy SDK - Transform

SDK

https://lw.microstrategy.com/msdz/MSDL/_CurrentGARelease/docs/projects/WebSDK/default.htm#topics/bestpract/BP_Find_the_closest_transform.htm?Highlight=report
https://lw.microstrategy.com/msdz/MSDL/_CurrentGARelease/docs/projects/WebSDK/default.htm#topics/objbeans/Customizing_Transforms.htm?Highlight=report
https://lw.microstrategy.com/msdz/MSDL/_CurrentGARelease/docs/projects/WebSDK/default.htm#topics/objbeans/Web_Beans_and_Transforms.htm

What is a transform?

Transforms are reusable Java components that render the data on a MSTR Web page. Transforms cause the data stored in a given web bean to be presented according to the rules defined by the transform. Transforms are responsible for converting the data within a Web bean into its final output representation.

Creating a new transform requires Java programming skills and is not covered in this topic. However, the MicroStrategy Web architecture was designed so that many customizations can be accomplished by simply modifying the layout definition or parameters for an existing transform.

This allows you to customize the way that data is presented without creating a new transform class. Before you decide to write a custom transform, you should review the information contained in the Transform Parameters Reference to see if your customization can be accomplished more easily by using an existing transform.

How can we launch the Transform Creation Wizard?

  1. Launch the MSTR Web Customization Editor
  2. Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list comprises the different settings that can be modified to perform customizations.
  3. Click on Styles to expand the list of styles used in MicroStrategy Web.
  4. Right-mouse click any style and select Create Transform to launch the Transform Creation Wizard
  5. http://community.microstrategy.com/t5/tkb/articleprintpage/tkb-id/web/article-id/837

Sample code for creating a transform:

package com.yourcompany.microstrategy.custom.transforms;

import com.microstrategy.web.app.transforms.ReportGridCellRowHeaderImpl;
import com.microstrategy.web.beans.BeanContext;
import com.microstrategy.web.beans.MarkupOutput;
import com.microstrategy.web.beans.WebComponent;
import com.microstrategy.utils.log.Level;
import com.microstrategy.web.app.tags.Log;
import com.microstrategy.web.objects.WebHeader;
import com.microstrategy.web.objects.WebWorkingSet;

public class CustomReportGridCellRowHeaderImpl extends ReportGridCellRowHeaderImpl { 

    private boolean linkEventID = false;
    /**
    * Default constructor for the class
    **/
    public CustomReportGridCellRowHeaderImpl() {
        super();
    }

    public String getDescription() {
        return "Link Event ID to preview";
    }

    public void generatePreContent(MarkupOutput mo) {
        String methodName = "processRequest";
        String rowTitle = "";
        linkEventID = false;
        Log.logger.logp(Level.INFO,  this.getClass().getName(), methodName,"generatePreContent invoked!");

        WebHeader header = getWebHeader();

        if (header != null) {
            rowTitle = header.getTitle().getDisplayName().toUpperCase().replaceAll(" ","");
            Log.logger.logp(Level.INFO,  this.getClass().getName(), methodName,"rowTitle:" + rowTitle);
            if ((rowTitle.equalsIgnoreCase("EVENTID")) || (rowTitle.equalsIgnoreCase("TICKETID"))) {
                String projectName = this.getViewBean().getSessionInfo().getFactory().getIServerSession().getProjectName();
                projectName = projectName.toUpperCase().replaceAll(" ","");
                if (projectName.indexOf("PROJECT A") > -1) {
                    linkEventID = true;
                }
                if (projectName.equals("PROJECT B")) {
                    linkEventID = true;
                }
                if (projectName.indexOf("PROJECT C") > -1) {
                    linkEventID = true;
                }

                Log.logger.logp(Level.INFO,  this.getClass().getName(), methodName,"Project Name:" + projectName);
            }
        }
        super.generatePreContent(mo);

        if (linkEventID) {
            String eventID = this.getText();
            mo.append("<a href=\"javascript:void(0)\" onclick=\"top.frmMenu.linkEventIDFromMicroStrategyReport('" + eventID + "')\">") ;
        }
    }

    /**
    * Generate the post-contents of the cell
    * @param mo the MarkupOutput object
    **/
    public void generatePostContent(MarkupOutput mo) {
        if (linkEventID) {
            mo.append("</a>");
        }
        super.generatePostContent(mo);
    }
}

A transform is used in association with a Style. Using the Web Customization Editor, expand Application Settings, drill down on Styles, find the style that you need to change, double click it, and click on the Change button to change the transform.

What other information do I know about transform?

The entry point method is transform(Transformable, MarkupOutput). This method calls the method initializeTransform(Transformable) and the method renderShell(MarkupOutput); all these methods can be overriden by any class extending the AbstractAppTransform class and take advantage of this predefine flow.

The renderShell(MarkupOutput) outputs the basic container of the transform. This container consists of a <DIV> tag that holds the name and information the application requires to interact with the bean. Information in this shell includes whether the bean can be updated using the iframe update technology, whether the bean appears as a popup dialog and the name of the javascript class associated, if any.

The javascript class informs the DHTML code the bone associated with this component. A bone is the corresponding concept of a bean in Microstrategy's javascript environment. Those Transforms that require a bone should override the getScriptClass() method.

The renderShell method will then call the checkStatus(MarkupOutput) method. The latter, based on the XML status (EnumRequestStatus) of the report will call:

  • transformForRequestCanceled(MarkupOutput)
  • transformForRequestInError(MarkupOutput)
  • transformForRequestNotInited(MarkupOutput)
  • transformForRequestProcessing(MarkupOutput)
  • transformForRequestSuccessful(MarkupOutput)
  • transformForRequestWaitingForUserInput(MarkupOutput)

Transforms inherits from AbstractTransform

See also:

How can we figure out the style or transforms that we need to modify?

Using the IE Developer Tool, we can copy the innerHTML of the body tag, and paste it into Notepad++, and do a case-sensitive search for "Style". A transform is used in association with a Style. You can then search the Internet for the name of that style, and it should bring up relevant TNs for what you want to do. Using the Web Customization Editor, expand Application Settings, drill down on Styles, find the style that you need to change, double click it, and click on the Change button to change the transform.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License