2012-05-25 7 views
9

私は単一のパラメータを取る簡単なレポートを作成しました。このパラメータはクエリで使用され、レポートデザイナで直接実行されたときに正常に実行されます。ところで、このレポートではJavaScriptやスクリプトを使用していません。私はいくつかの人々がスクリプトやJavaScriptを使ってパラメータを渡そうとしているのを見ましたが、これは私がやっていることではありません。私はjavaを介してすべてのパラメータを渡します。引き続き、このレポートでは、アクティブ/非アクティブ項目をリストしています。非アクティブなアイテムを表示するには「N」を、アクティブなアイテムには「Y」を渡します。私はAPIを介してパラメータを渡そうとすると、渡されたものに関係なく、常にアクティブなアイテムのリストを取得します。ところで、 'Y'は渡されたパラメータのデフォルト値です(私はデフォルトの下のコード)私が抱えている問題は、レポートが設定したパラメータを取りたいと思わないということです。はい、変数の値の変更は渡されましたが、レポートには変更が反映されません。私のコードは以下の通りです。私はこのリンクのアドバイスとパラメータの設定方法に従おうとしました。BIRTレポートデザイナーがBIRT APIを通じて作成したBIRTレポートに、どのようにパラメータを設定して渡しますか?

http://www.eclipsezone.com/eclipse/forums/t67723.html

あなたがリンクに行けば#4まで行き、実行するタスクのリストを参照してください。これは私が従おうとしていることです。私は何かが欠けているかもしれないと感じる。あなたがこれを持っているなら、私が逃しているものにいくつかのアドバイスをくれますか?どうもありがとう!

は-Dale

public class ReportGenerator { 
     public static void main(String args[]) throws Exception{ 
     ReportGenerator rg = new ReportGenerator(); 
     rg.executeReport("N"); 
     } 


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

     IReportEngine engine=null; 
     EngineConfig config = null; 

     try{ 
      config = new EngineConfig();    
      config.setBIRTHome("C:\\birt-rcp-report-designer-3_7_2\\ReportEngine"); 
      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); 
      parameterDefinitionTask.evaluateDefaults(); 
      HashMap<String, String> params = parameterDefinitionTask.getDefaultValues(); 
      params.put("aIndicator", activeIndicator); 
      parameterDefinitionTask.setParameterValues(params); 

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

      PDFRenderOption options = new PDFRenderOption(); 
      options.setOutputFormat("pdf"); 
      options.setOutputFileName("C:\\workspace\\SimpleReport\\output\\itemListingReport.pdf"); 

      task.setRenderOption(options); 

      task.run(); 
      task.close(); 
      engine.destroy(); 
     } catch (Exception ex) { 
      ex.printStackTrace(); 
     } finally { 
      Platform.shutdown(); 
     } 
     } 
    } 

答えて

11

あなたはIRunAndRenderTaskにパラメータを設定する必要があります。

IRunAndRenderTask task = 
    engine.createRunAndRenderTask(reportRunnable); 
Map< String, Object > birtParams = ...; 
task.setParameterValues(birtParams); 
+0

を(BIRT 4前)以前のバージョンでは、私がしなければならなかったすべては、新しいEngineConfig()でした。 setAppContext(birtParams)。 –

関連する問題