Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[birt-report-engine-dev] Calling BIRT Report Viewer from Struts Action class

Hi,

I have integrated struts and BIRT, and it's working fine...
I am using HTMLRenderOption and 'run' to get the report..That much is
working fine..
Now what I want is, the report to come in BIRT Report Viewer (with
frameset). 


This is my code in struts action class..

//get the parameters passed from jsp form..
//do some work on the params
......
// configure engine
EngineConfig engineConfig = new EngineConfig();
...
ServletContext sc = req.getSession().getServletContext();
IPlatformContext context = new PlatformServletContext( sc );
engineConfig.setPlatformContext( context );
Platform.startup( engineConfig );

//create factory and create birt engine
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine birtEngine = factory.createReportEngine( engineConfig);  

//put params from JSP in to a hashmap
HashMap params = new HashMap();
params.put("p_1",param1);
params.put("p_2",param2);

//create report design
design =
birtEngine.openReportDesign(sc.getRealPath("/Reports")+"/"+"myreport.rptdesign");

//create task
IRunAndRenderTask task = birtEngine.createRunAndRenderTask(design);
 HTMLRenderOption options = new HTMLRenderOption();
javax.servlet.ServletOutputStream sosStream = null;
sosStream = resp.getOutputStream();
options.setOutputStream(sosStream);
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
task.setParameterValues(params);
task.validateParameters();
task.setRenderOption(options);
task.run();
task.close();
birtEngine.destroy();   

//for struts...
return mapping.findForward(null);

Since I am not giving any explicit url I can not give some thing like
"frameset?__report=Report/myreport.rptdesign"

is there any provision to view the report in BIRT Report Viewer by setting
parameters in "options" "task" or soome where?

One way is to use 
********
<%@ taglib uri="/WEB-INF/birt.tld" prefix="birt" %>

<body>
<birt:viewer id="birtViewer" reportDesign="/test.rptdesign"
showParameterPage="true" pattern="frameset" 
	height="450" width="700" format="html">
</birt:viewer>
</body>
**********


but in this case i wont have the flexibility to manipulate parameters passed
from JSP ....

Thanx in advance,
regs
reji
-- 
View this message in context: http://www.nabble.com/Calling-BIRT-Report-Viewer-from-Struts-Action-class-tp21704190p21704190.html
Sent from the Eclipse BIRT - Report Engine - Dev mailing list archive at Nabble.com.



Back to the top