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 JAR files must be accessible by the Java Runtime
Environment. The Strategy Web JAR files can be found under:
Note:
More elaborate programs will require additional library files and are out of the scope of this document.
Users may want to change graph properties on the fly when a report is run. This can be done through an Add-on with the RequestKeys.
package com.Strategy.sdk.samples.addons;
import com.Strategy.web.app.addons.AbstractAppAddOn;
import com.Strategy.web.app.beans.PageComponent;
import com.Strategy.web.beans.GenericRequestKeys;
import com.Strategy.web.beans.GenericWebEvent;
import com.Strategy.web.beans.ReportBean;
import com.Strategy.web.beans.RequestKeys;
import com.Strategy.web.beans.ViewBean;
import com.Strategy.web.beans.WebBeanException;
import com.Strategy.web.beans.WebException;
import com.Strategy.webapi.EnumDSSXMLExecutionFlags;
import com.Strategy.web.beans.WebComponent;
import com.Strategy.web.objects.WebGraph;
import com.Strategy.web.objects.WebObjectsException;
public class SeriesByColumn extends AbstractAppAddOn{
public String getAddOnDescription(){
return"Change graph properties and set series by column";
}
public void preCollectData(PageComponent pageComponent){
ReportBean rb=getReportBean(pageComponent);
if(rb!=null){
try{
rb.getReportInstance().setAsync(false);
rb.setExecutionFlags(EnumDSSXMLExecutionFlags.DssXmlExecutionResolve);
rb.collectData();
ViewBean vb=rb.getViewBean();
rb.collectData();
RequestKeys frameKeys=new GenericRequestKeys();
frameKeys.add(GenericWebEvent.URL_EVENT_NAME,"4096021");
frameKeys.add(GenericWebEvent.URL_SOURCE_NAME,"vb.4096021");
frameKeys.add("seriesByColumns","0");
frameKeys.add("majorType","64");
frameKeys.add("applyNow","1");
vb.handleRequest(frameKeys);
vb.collectData();
}
catch(WebBeanException e){
e.printStackTrace();
}
catch(WebObjectsException e){
e.printStackTrace();
}
catch(WebException e){
e.printStackTrace();
}
}
}
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;
}
}