Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Passing a Bean Object to BIRT
gjergj
Hi to all, i'm newbie with BIRT..
I have my method in a java class addUrlParam("value", key)that pass 2 strings argument, but the thing is that i need to pass a bean to BIRT and then in the report source inwant to take this bean and to give like an argument to a method that i call .
I tried with JSON but when i get the bean in BIRT it doesn'ìt goes OK !!!
First Part within the java class:
JSONObject jsonObj= it.cons.client.util.JSONUtil.toJSONObject(myBean);
String str=jsonObj.toString();
repUtil.addUrlParam("myBeanSTR", str);
In the Report :
myBeanSTR=(params["myBeanSTR"] == "default")?null:(params["myBeanSTR"]);
myBean=(Packages.it.gez.rimsi.common.bean.ContBean)Packages.it.client.util.JSONUtil.fromJSONObject(myBeanSTR,ContBean.class);
does someone ever passed a bean object to a BIRT Report ?
thanks to all
Find more posts tagged with
Comments
rmurphy
Are you using the Report Engine API to generate the report? If so, you can set your bean in a Map and call the setAppContext method on your engine task (e.g. IRunTask, IRenderTask, IRunAndRenderTask). Here is a code sample.<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public void run(String designName, String reportDocument, Object myObject) throws EngineException{
design = engine.openReportDesign( designName );
IRunTask task = engine.createRunTask( design );
HashMap contextMap = new HashMap();
contextMap.put("MyKey", myObject);
task.setAppContext(contextMap);
task.run( reportDocument );
task.close();
}
</pre>
<br />
<br />
Then you can access the appContext in your report design's script using reportContext.getAppContext();<br />
<br />
Rob
gjergj
hi Rob, thank you for your response..
yes i'm using Report Engine API to generate my reports, i'm going to try immediatly your idea