<p>Hey there,</p>
<p> </p>
<p>I'm using Birt in a spring boot application and I'm trying to call my service bean method in the open() script method, but I couldn't get the application context using the typical code<br>
</p>
<pre class="_prettyXprint _lang-js">
importPackage(Packages.org.springframework.context);
importPackage(Packages.org.springframework.web.context.support );
//ServletContext
var sc = reportContext.getHttpServletRequest().getSession().getServletContext();
//ApplicationContext
var spring = WebApplicationContextUtils.getWebApplicationContext(sc);
var mypojo = spring.getBean("carService");
this.text = mypojo.getAllCars().get(0).getMake();
</pre>
<p>I saw that there is a way to use java object to call open method, because it will get me out of the problem of getting the context but how can where should I save the list of objects after callen the service in code bellow?</p>
<pre class="_prettyXprint _lang-js">
public class DocScriptedDataSet extends ScriptedDataSetEventAdapter {
public int recordCount = 0;
@Override
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow row) {
try {
if (recordCount < 20) {
recordCount++;
row.setColumnValue("col1", recordCount);
row.setColumnValue("col2", "Count = " + recordCount);
row.setColumnValue("col3", recordCount * .05);
return true;
} else {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
public void open(IDataSetInstance dataSet) {
recordCount = 0; //here I should call my service and get the list of objects, but where I have to save them?
}
}
</pre>