2012-01-24 23 views
6

BIRTレポートエンジンをTomcatの既存のWebアプリケーションに追加したいと思います。私はBIRTビューアを必要としません、私は実際にはhttp://localhost:8080/birt/output?__report=test.rptdesign&sample=my+parameterのようなURLからレポートを実行し、異なるエクスポートオプションpdf、xls、doc、htmlを使用できるようにしたいだけです。既存のWebアプリケーションにBIRTを統合

私が今までに見つけた統合ガイドにはすべて、ビューアとさまざまなフォーマットを扱うための独自のサーブレットを作成することが含まれています。

私は必要なレポートエンジンのweb.xmlファイルからどのサーブレットマッピングを知っていて、既存のwebappのこのベアボーンBIRT実装用にlibディレクトリからインクルードする必要があるのか​​を知りたいと思っていました。

答えて

17

私は誰か、単に私が必要 レポート・エンジンのweb.xmlファイルからサーブレットマッピングを知っていた期待していたと私は に必要と思われるjarファイルは、既存のWebアプリケーションでは、このベアボーンBIRT実装 のためのlibディレクトリから含まれています。

私は必ずしも私はちょうど「私はドンように、私の既存のWebアプリケーションに独自のスタンドアロンWebアプリケーション(「ランタイム」ボタンの下here)から既存のレポートのランタイムを統合したかった私自身のサーブレットを書きたくありませんでしたBIRTレポートの実行をサポートするために2つのWebアプリケーションを配布する必要があります。申し訳ありませんが、それが明確でない場合。

  1. 必要なのは、次のサーブレットマッピングがに追加されます。

    私は、誰もが(BIRTランタイム3.7.1を使用して)同様の質問がある場合には、できるだけ簡単な方法で、しかし、これをうまくありませんでしたあなた自身のwebapp\web-inf\web.xmlファイル:自分のwebapp\web-inf\libディレクトリに

    <!-- Engine Servlet --> 
    <servlet> 
        <servlet-name>EngineServlet</servlet-name> 
        <servlet-class>org.eclipse.birt.report.servlet.BirtEngineServlet</servlet-class> 
    </servlet> 
    
    <servlet-mapping> 
        <servlet-name>EngineServlet</servlet-name> 
        <url-pattern>/output</url-pattern> 
    </servlet-mapping> 
    
  2. runtimeweb-inf\libディレクトリからすべてのjarファイルを含めますectory。

あなたはその後、例えば、独自のWebアプリケーションからoutput BIRTレポートのURLを使用して、あなたが好きなフォーマット指定.rptdesignファイルを実行することができます。このため

http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=pdf 
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=html 
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=xls 
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=doc 
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=ppt 
+3

素晴らしい答え、Stack Overflowへの功績。完了し、正確に求められたもの。よくできました。 – MystikSpiral

+0

revisited - 4.2.2でも有効 – Geronimo

+0

Tomcat 7のBIRT 4.3.2で動作します。3.7.1または4.3.2ではJettyでは動作しませんでした。 – Ryan

1

あなたが理解しているように、どこかの場所に* .rptdesignがあるサーブレットのbirtレポートフォームを生成しようとしています。

良い、あなたがタイプIReportRunnableからレポートのインスタンスを取得し、その後BIRTエンジンを準備しなければならない最初のものを見ることができるように、次のコード

this.bundle = ResourceBundle.getBundle("com.tts.mersal.resources.MersalResources"); 
this.config = new EngineConfig(); 
this.config.setEngineHome(bundle.getString("BIRT_ENGINE_HOME")); 
this.config.setLogConfig(bundle.getString("BIRT_LOGGING_FOLDER_PATH"), Level.ALL); 
Platform.startup(config); 
this.factory = (IReportEngineFactory)Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY); 
this.engine = factory.createReportEngine(config); 
this.engine.changeLogLevel(Level.ALL); 
ContentReader contentReader = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getFileFolderService().getReader(MersalOutboundReportDialogBean.this.dialogReportNode.getNodeRef()); 
IReportRunnable report = MersalOutboundReportDialogBean.this.getEngine().openReportDesign(contentReader.getContentInputStream()); 
ReportDesignHandle designHandle = (ReportDesignHandle)report.getDesignHandle(); 
OdaDataSource source = (OdaDataSource)designHandle.getModule().findDataSource(DATA_SOURCE_NAME); 
source.setProperty(source.getPropertyDefn("FILELIST"), buildUrl((String)source.getProperty(designHandle.getModule(), "FILELIST"))); 
IRunAndRenderTask runAndRenderTask = MersalOutboundReportDialogBean.this.getEngine().createRunAndRenderTask(report); 
HTMLRenderOption render = new HTMLRenderOption(); 
render.setOutputFileName("G:/Render.html"); 
render.setOutputFormat("html"); 
runAndRenderTask.setRenderOption(render); 
runAndRenderTask.run(); 
runAndRenderTask.close(); 

を見て、あなたがその場所を設定することができた後、あなたの要求に基づいて変更されるオプションを使用して出力の

複数のchocies、HTMLRenderOption、PDFRenderOptionなどがあります。

私はあなたに役立つことを願っています。

ありがとうございました。

+0

おかげで、私は主に統合しようとしていました私自身のwebappの既存のランタイム。もしこれがもっとはっきりしなかったら、申し訳ありません。私はこれを以下で解決しました。 – Geronimo

+0

+1がBirtEngineServletの背後でどのように機能するかを示すために+1 – dragon66

関連する問題