The Strategy SDK allows useres 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, refer to the Strategy Developer Zone at https://support.Strategy.com/MSDL/home.asp.
To access the Strategy Developer Zone, a user must have access to the Strategy Knowledge Base, must have purchased the Strategy SDK, and must be current on their 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, contact Strategy Technical Support at support@Strategy.com or at (703) 848-8700. If you are an international business, contact Strategy Technical Support at the appropriate email address or phone number found at http://www.Strategy.com/Support/ContactUs.asp.
The example provided in this document is provided "as-is" to the user and assumes that the user:
PREREQUISITES:
For the sample to work, the Strategy Web 9.x JAR files must be accessible by the Java Runtime Environment. The Strategy Web 9.x JAR files can be found under:
NOTE: More elaborate programs will require additional library files and are out of the scope of this document.
The following add-on code sample for Strategy Web SDK 9.x demonstrates how to execute custom code for a specific project based on its project ID and/or its project name. The add-on can be executed when clicking 'My Reports', editing a report, executing a report, etc.
For more information about customizing with Add-ons, click the following link:
https://resource.microstrategy.com/MSDZ/MSDL/930/docs/mergedProjects/websdk/topics/webcusteditor/custtasks/WCE_Creating_a_New_Add-on_for_a_Page.htm#bc-1
Sample Code/Error
package custom.sdk.samples;
import com.Strategy.web.app.addons.*;
import com.Strategy.web.beans.*;
import com.Strategy.web.app.beans.*;
/*
*
* The ConditionOnProjectAddOn class is an add-on for Strategy Web that
* can execute custom code for a specific project based on its
* project ID and/or its project name.
*
* Note: The code used to condition on project id has been commented out on purpose.
* This class will demostrate how to execute custom code based on project name.
*/
public class ConditionOnProjectAddOn extends AbstractAppAddOn {
private final String name = "Tutorial Project";
// private final String id = "0D9D6DD4444076D4FC729D9C5D4E6EFE";
/**
* Returns the description for the this addon
*/
public java.lang.String getAddOnDescription() {
return "This add on executes code based on a project's Name";
}
/**
* main execution method, passed in an instance of the appropriate page component
**/
public void preCollectData(PageComponent pageComponent) {
try {
// Obtain Project Name
String projectName = pageComponent.getAppContext().getAppSessionManager()
.getActiveSession().getProjectName();
// Obtain Project ID
// String projectID = pageComponent.getAppContext().getAppSessionManager()
// .getActiveSession().getProjectID();
// Obtain the Report Bean that this component represents
// The Report Bean will not be used in this example.
ReportBean _rb = getReportBean(pageComponent);
if (_rb == null)
return;
// Check if a Prompt Bean exists
// PromptsBean _pb = _rb.getPromptsBean();
// if (_pb == null)
// return;
//Verify that either projectName is valid.
if (projectName == null || !projectName.equals(name)) {
return; // exit if condition fails, else resume.
}
// Verify that either projectID is valid.
// if (projectID == null ||!projectID.equals(id)) {
// return; // exit if condition fails, else resume.
// }
/* The condition is valid, continue executing code */
}
catch (Exception ex) {
ex.printStackTrace();
}
}
/*
* Checks whether a web component is a report bean and returns that
* bean if found, returning null otherwise.
* Notice that search is recursive for components below the current
*/
private static ReportBean getReportBean(WebComponent wc) {
ReportBean __result = null;
if (wc instanceof ReportBean) {
__result = (ReportBean) wc;
} else {
for (int i = 0; i < wc.getChildCount(); i++) {
__result = getReportBean(wc.getChild(i));
if (__result != null)
break;
}
}
return __result;
}
}
ConditionOnProjectAddOn
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 an Account Executive to inquire about Strategy Consulting assistance.