EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB31309: How to Display the Metric Value as a Tooltip when the Metric Cell is Showing a Threshold Image using the MicroStrategy Java Web SDK 10.x


Community Admin

• Strategy


How to Display the Metric Value as a Tooltip when the Metric Cell is Showing a Threshold Image using the MicroStrategy Java Web SDK 10.x

SCENARIO
When defining thresholds (using either Strategy Web or Developer) it is possible to display an image based on a condition instead of the metric value. By default, the metric value is no longer visible, and only the threshold image displays, as shown in the following screenshot:

ka04W000000OeH6QAK_0EM440000002Gvw.jpeg

 
 
This is the default behavior when working with thresholds in Strategy. However, it may be desirable to still see the metric value as well as the image.
 
 
There are many ways this can be accomplished. For example, it can be accomplished by creating a derived metric which is identical to the existing metric, and then apply the thresholding to this derived metric, leaving the original metric values intact. 
 
Another way to accomplish this is by performing a customization in Strategy Web where the metric value can appear as a tooltip when the mouse is hovering over the threshold image.
 
To accomplish this customization, these steps are required: 
1. Create a custom addon to include a result flag that will bring back the raw data of the report (in addition to the formatted data). 
2. Create a custom grid class transform that extends the ReportGridCellMetricValueImpl class and override the generateTooltipContent() method to generate the custom tooltip content. 
3. Configure this grid customization to be available for all reports or for specific reports.
 
Once the customization is complete, the metric value will appear as a tooltip when hovering over the cell as shown below:

ka04W000000OeH6QAK_0EM440000002GvZ.jpeg

 
STEPS
To implement this customization, perform the following steps in detail:
 
Part 1. Create a custom addon to include a result flag that will bring back the raw data of the report (in addition to the formatted data). 
1. Using the Web Customization Editor (WCE), create a new plugin named 'ShowValueAndThreshold'.
2. Switch to the Application Settings tab (Strategy View should be open) and expand 'Pages'
3. Right-click on the page named 'report' and click 'Create New Addon'. The name of the new Addon should be 'CustomReportFlags' and is a 'preCollectData' addon.
 
For step-by-step instructions for creating a new addon using the Web Customization Editor (WCE), click here.
 
4. Replace the auto-generated code with the following Addon code:
 


package customclasses.addons; //Specify correct package name here


import com.Strategy.web.app.addons.AbstractAppAddOn;
import com.Strategy.web.app.beans.PageComponent;
import com.Strategy.web.beans.ReportBean;
import com.Strategy.webapi.EnumDSSXMLResultFlags;

public class CustomReportFlags extends AbstractAppAddOn {
    public String getAddOnDescription() {

        return "Including XML Raw Data with XML result so we can get the metric value that the threshold is replacing";

    }

    public void preCollectData(PageComponent page) {
        System.out.println("Calling CustomReportFlags Addon");
        ReportBean rb = (ReportBean) page.getChildByClass(ReportBean.class);

        if (rb == null) return;


        /*TODO: Add additional custom logic here to apply this customization
        for only specific reports (or to exclude very large reports)
        as this result flag will increase the size of the XML sent to Web*/

        rb.setResultFlags(rb.getResultFlags() | EnumDSSXMLResultFlags.DssXmlResultRawData);

        return;
    }

  
5. Save and close the java file (it should automatically compile when saving if 'Build Automatically' is checked).
 
Part 2. Create a custom grid class transform that extends the ReportGridCellMetricValueImpl class and override the generateTooltipContent() method to generate the custom tooltip content.
1. Open Windows Explorer and navigate to the gridclasses.properties file located under Strategy/WEB-INF/classes/resources
2. Make a copy of this file and save under  your plugin folder (replace $CUSTOMPLUGIN$ with the actual plugin name created in Step 1):
Strategy/plugins/$CUSTOMPLUGIN$/WEB-INF/classes/resources  (create the file structure if it is not already there)
 
3. Important: Rename this copied file to CustomgridClasses.properties
4. Now switch back to the Web Customization Editor (WCE).
5. Navigate back to the 'Application Settings' tab and expand 'Strategy Web Configuration' if it's not already expanded.
6. Right-click on 'Styles' and click 'Create Transform'.
7. In the 'Transform Creation Wizard', specify the following fields:
 

Source folder: Source Folder designated in the WCE
Package: $CUSTOMPACKAGENAME$
Name: ThresholdAndValueMetricValue
Transform Description: Custom Transform to display metric value as tooltip when there is a threshold image present
Superclass: com.Strategy.web.app.transforms.ReportGridCellMetricValueImpl
Open new style wizard: Unchecked

  
8. Click Next, Next again, then Finish.
9. Replace the auto-generated code with the following transform code:
 

package customclasses.transforms; //Specify correct package name here

import java.text.NumberFormat;
import com.Strategy.web.app.transforms.ReportGridCellMetricValueImpl;
import com.Strategy.web.objects.WebRowValue;

public class ThresholdAndValueMetricValue extends ReportGridCellMetricValueImpl {

    public String getDescription() {
        return "Custom Transform to display metric value as tooltip when there is a threshold image present";
    }

    @Override
    protected String generateTooltipContent() {
        /*TODO: Add additional custom logic here to apply this customization
           for only specific reports. If the report being rendered does not match the
           the designated reports, then call super.generateTooltipContent() */

        //get the current tooltip content (value could be null)
        String strTooltip = super.generateTooltipContent();

        //Get the cell value currently being rendered     
        WebRowValue value = getWebRowValue();

        //Check if the value is an Web URL which in this case is pointing to the threshold image
        if (value.getValue().startsWith("http")) {
            //Convert the value to double
            double dbl = Double.parseDouble(value.getRawValue());

            //the raw value contains no formatting, so we are going to apply the currency number formatter to the value
            NumberFormat nf = NumberFormat.getCurrencyInstance();
            strTooltip = nf.format(dbl);
        }
        return strTooltip;
    }

}

 
10. Save and close the java file.
 
Part 3. Configure this grid customization to be available for all reports or for specific reports. 
1. Expand the 'Property Files section and browse to WEB-INF/classes/resources and double-click to open it in the editor.
2. Right-click 'metricValue' and click 'Edit. Specify the custom transform created in step 2 (be sure to use the correct package name):
 

customclasses.transforms.ThresholdAndValueMetricValue

 
3. Save and close the editor.
 
 
 
To apply this customization on all reports:
1. Expand 'Styles' on the 'Application Settings' tab and search for the style named 'ReportGridStyle'. Double-click on it to open it in the editor
2.  Switch to the 'Style Parameters' tab and click 'Add'.
3. Search for 'gridClassesConfFile' and add it to the list on the right. Click OK.
4. The new parameter should appear last in the list. Select it and specify 'CustomgridClasses.properties' as its value. Click Save.
5. Close the style editor. 
6.  Restart the web or application server, then run a report with thresholds to see the results.
 
 To apply to only specific reports:
1. Expand 'Styles' on the 'Application Settings' tab and search for the style named 'ReportGridStyle'.
2. Right-click on this style and choose 'Duplicate'. The duplicated style will automatically open up in the editor.  Don't worry about the name now as it will be changed in a later step.
3. Switch to the 'Style Parameters' tab and click 'Add'.
4. Search for 'gridClassesConfFile' and add it to the list on the right. Click OK. 
5. The new parameter should appear last in the list. Select it and specify 'CustomgridClasses.properties' as its value. Click Save.
6. Close the style editor. 
7. Browse for this new, duplicated style (named 'CopyOfReportGridStyle' by default), right-click it and choose rename. Rename this style to ReportGridStyleThresholdAndValue. Click OK.
8. Modify the custom addon and transform written in steps 1 and 2 (see TODO comments) to add the conditional logic to first check for the report being executed/rendered and if the report should have the threshold customization, then dynamically apply the custom style 'ReportGridStyleThresholdAndValue'. 
9. After making changes to the code, restart the web or application server, run a report that meets the custom condition to see the changes.
 
The example provided in this document is provided “as-is” to the user and assumes that the user:

  • Can program, compile (e.g. javac, jikes, etc.), and execute Java programs
  • Can configure environment variables (e.g. JAR files, property files, etc.)
  • Have all the necessary tools to create Java applications (JDK, IDE, etc.)
  • Has access to the Strategy SDK documentation.
  • Has read the customization warning at the bottom of this document

 
PREREQUISITES:
For the sample to work, the Strategy Web JAR files must be accessible by the Java Runtime
Environment. The Strategy Web JAR files can be found under:

  • Strategy Web Universal (JSP): {web_root}/WEB-INF/lib directory.
  • Strategy Web (.NET): Program Files\Common Files\Strategy directory.

Note:
More elaborate programs will require additional library files and are out of the scope of this document.
 
ADDITIONAL INFORMATION:
The Strategy SDK allows you to customize the standard Strategy Web interface, and extend and integrate the Strategy business intelligence functionality into other applications. However, before changing the way Strategy Web products look or behave, it is helpful to understand how the application is built. For more information regarding the Strategy Web architecture or the process of customizing Strategy Web, please refer to Strategy Developer Zone (https://resource.microstrategy.com/msdz/).
 
To access the Strategy Developer Zone, you must have access to the Strategy Knowledge Base, you must have purchased the Strategy SDK, and you must be current on your Strategy maintenance agreement. If you are a US-based business and believe that you satisfy all three of these conditions but you do not have access to the Strategy Developer Zone, please contact Strategy Technical Support at support@microstrategy.com or at (703) 848-8700. If you are an international business, please contact Strategy Technical Support at the appropriate email address or phone number found at http://www.microstrategy.com/Support/ContactUs.asp.
 
CUSTOMIZATION WARNING:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.
 
 


Comment

0 comments

Details

Knowledge Article

Published:

June 12, 2017

Last Updated:

June 12, 2017