Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How can I pass a parameter to my report?(Trying to set and pass a parameter to a BIRT report created by the BIRT Report Designer through the BIRT API)
How can I pass a parameter to my report? [message #876814] Fri, 25 May 2012 10:10 Go to next message
Dale DeMott is currently offline Dale DeMottFriend
Messages: 1
Registered: May 2012
Junior Member
I've created a simple report that takes a single parameter. This parameter is used in the query and executes fine when directly executed in the report designer. By the way I'm not using javascript or any scripting for this report. I've seen some people trying to pass parameters using scripts and/or javascripts for answers here, however this is not what I'm doing. I pass all my parameters in through java. Continuing, in this report I'm listing active/inactive items. I pass in an 'N' for listing inactive items and a 'Y' for active items. When I try to pass in a parameter through the API, I always get a list of active items regardless to what I pass in. By the way 'Y' is the default value of the parameter passed in. (I am overriding the defaults in the code below) The problem I'm having is that the report doesn't seem to want to take the parameter I set. My code is below.

Thanks much!

        public class ReportGenerator {
            public static void main(String args[]) throws Exception{
            ReportGenerator rg = new ReportGenerator();

            @SuppressWarnings({ "unchecked", "deprecation" })
            public void executeReport(String activeIndicator) throws EngineException {

            IReportEngine engine=null;
            EngineConfig config = null;

                config = new EngineConfig( );            
                config.setLogConfig("c:/temp/test", Level.FINEST);
                Platform.startup( config );
                IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
                engine = factory.createReportEngine( config );        

                IReportRunnable reportDesign = null;
                reportDesign = engine.openReportDesign("C:\\workspace\\SimpleReport\\ReportTemplates\\ItemListingReport.rptdesign"); 
                IRunAndRenderTask task = engine.createRunAndRenderTask(reportDesign);
                IGetParameterDefinitionTask parameterDefinitionTask = engine.createGetParameterDefinitionTask(reportDesign);
                HashMap<String, String> params = parameterDefinitionTask.getDefaultValues();
                params.put("aIndicator", activeIndicator);

                ConnectionHelper connectionHelper = new ConnectionHelper();
                task.getAppContext().put("OdaJDBCDriverPassInConnection", connectionHelper.getConnection());

                PDFRenderOption options = new PDFRenderOption();


            } catch (Exception ex) {
            } finally {

Re: How can I pass a parameter to my report? [message #876933 is a reply to message #876814] Fri, 25 May 2012 14:32 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member


You need to set the parameter on the RunAndRenderTask.

RunAndRenderTask task = engine.createRunAndRenderTask(reportDesign);
task.setParameterValue or task.setParameterValues.

You do not need a parameter definition task to set the parameters.
Generally this task is used to build a custom ui as it gets design
information on report parameters.


On 5/25/2012 6:10 AM, Dale DeMott wrote:
> RunAndRenderTask task = engine.createRunAndRenderTask(reportDesign);
Previous Topic:BIRT with Multiple Data sets
Next Topic:rap using the birt3.7.1, IReportEngineFactory is null
Goto Forum:

Current Time: Sun Nov 28 15:49:42 GMT 2021

Powered by FUDForum. Page generated in 0.01588 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top