Using the Strategy Java Web SDK 9.4.x, it is possible to pass in prompt answer xml as a parameter in the request when a specific report is run. This type of customization is helpful when the answer XML is already known and stored in the user's session either as a session attribute or as a temporary cookie. This can be accomplished using a custom report event handler. For more information about the Strategy page execution flow and the event handling process, see the following link:
Processing Events During Page Execution
Create a Custom Report Event Handler with the following code definition:
package customclasses.handlers;
import com.Strategy.web.beans.AggregatedEventHandler;
import com.Strategy.web.beans.EnumEventHandlerTypes;
import com.Strategy.web.beans.EnumReportBeanEvents;
import com.Strategy.web.beans.ReportBean;
import com.Strategy.web.beans.RequestKeys;
import com.Strategy.web.beans.WebBeanException;
import com.Strategy.web.beans.WebEvent;
import com.Strategy.web.beans.WebException;
public class AnswerPromptinReportEventHandler extends
AggregatedEventHandler implements EnumReportBeanEvents {
WebEvent event;
ReportBean rb;
//change the report ID to reflect a valid report in the custom environment
String strReportID = "2C825EA14436B7FFBAA94B960814EDEA";
//the prompt answer XML, this can be retrieved from a session attribute or cookie in a customized environment
String answerXML = "<rsl lcl=\"1033\"><pa pt=\"4\" pin=\"0\" did=\"98EE6D294C3B1F5157214B954C50DA48\" tp=\"10\">2007</pa><pa pt=\"7\" pin=\"0\" did=\"6144DFEA4AC1D541B8FCEE9F2A720767\" tp=\"10\"><mi><es dirty=\"1\"><at did=\"8D679D4F11D3E4981000E787EC6DE8A4\" tp=\"12\" stp=\"3072\" n=\"Subcategory\" disp_n=\"Subcategory\"/><e ei=\"8D679D4F11D3E4981000E787EC6DE8A4:23\" emt=\"1\" art=\"1\" disp_n=\"Computers\" disp_id=\"1\"/><e ei=\"8D679D4F11D3E4981000E787EC6DE8A4:25\" emt=\"1\" art=\"1\" disp_n=\"TV's\" disp_id=\"2\"/><e ei=\"8D679D4F11D3E4981000E787EC6DE8A4:31\" emt=\"1\" art=\"1\" disp_n=\"Action\" disp_id=\"3\"/><e ei=\"8D679D4F11D3E4981000E787EC6DE8A4:26\" emt=\"1\" art=\"1\" disp_n=\"Video Equipment\" disp_id=\"4\"/><e ei=\"8D679D4F11D3E4981000E787EC6DE8A4:46\" emt=\"1\" art=\"1\" disp_n=\"Soul / R&B\" disp_id=\"5\"/></es></mi></pa></rsl>";
public AnswerPromptinReportEventHandler() {
super(EnumEventHandlerTypes.HANDLER_TYPE_REPORT);
}
public boolean processRequest(RequestKeys requestKeys) throws WebException {
// Retrieve the incoming event from the RequestKeys
event = getWebEvent(requestKeys);
if (event == null) {
// Let the default handler worry about this
return handleDefaultRequest(requestKeys);
}
//display the current event:
System.out.println("Current Event: " + event.getID());
rb = (ReportBean) getWebComponent();
if (rb == null) {
// Let the default handler worry about this
return handleDefaultRequest(requestKeys);
}
try {
if (rb.getObjectID().equalsIgnoreCase(strReportID)) {
//This is the report - pass answer xml in the request
System.out.println("Adding prompt answer xml to request");
requestKeys.add("promptsAnswerXML", answerXML);
}
} catch (WebBeanException e) {
e.printStackTrace();
}
return handleDefaultRequest(requestKeys);
}
}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:
ADDITIONAL INFORMATION:
The Strategy SDK allows you to customize several Strategy products and extend and integrate the Strategy business intelligence functionality into other applications. However, before changing the way Strategy products look or behave, it is helpful to understand how the application is built. For more information regarding the Strategy products or the process of customizing Strategy products, please refer to the MicroStrategy Developer Hub .
To access the Strategy Developer Hub, 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 Hub, please contact Strategy Technical Support at support@Strategy.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 https://www.Strategy.com/us/services/support/contact.
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.