Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Seam (BIRT) Recipe

Set up environment

Get started with Seam

#Generated by seam setup
#Sun May 11 07:49:04 CEST 2008
hibernate.connection.password=
workspace.home=/home/user/projects
model.package=org.seambirt.sample.entity
driver.jar=lib/hsqldb.jar
action.package=org.seambirt.sample
test.package=org.seambirt.sample.test
database.type=hsql
richfaces.skin=deepMarine
hibernate.default_catalog.null=
hibernate.default_schema.null=
database.drop=n
project.name=seambirt
hibernate.connection.username=sa
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
project.type=ear
icefaces.home=
database.exists=n
jboss.home=/opt/jboss-4.2.2.GA
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.connection.url=jdbc\:hsqldb\:.
  • Generate new entity ($ seam new-entity). I named it SampleReport.
  • [OPTIONAL] Include Seam project into your IDE. Eclipse Users: Add the project

into Eclipse using File > New > Project and select General > Project (not Java Project). NetBeans Users: Open the project in NetBeans.

Get started with BIRT

cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/com.ibm.icu_3.6.1.v20070906.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/commons-cli-1.0.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/coreapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/dataadapterapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/dteapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/engineapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/flute.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/chartengineapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/js.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/modelapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/modelodaapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/odadesignapi.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/org.apache.commons.codec_1.3.0.v200706111738.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/org.eclipse.emf.common_2.2.1.v200702131851.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/org.eclipse.emf.ecore.xmi_2.2.2.v200702131851.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/org.eclipse.emf.ecore_2.2.2.v200702131851.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/org.w3c.css.sac_1.3.0.v200706111724.jar $PROJECT/lib
cp $BIRT_RUNTIME/WebViewerExample/WEB-INF/lib/scriptapi.jar $PROJECT/lib
  • Copy dir (include subdirs) from $BIRT_RUNTIME/WebViewerExample/WEB-INF/platform to $PROJECT/resources/WEB-INF/platform
cp -r $BIRT_RUNTIME/WebViewerExample/WEB-INF/platform $PROJECT/resources/WEB-INF/platform

Integrate

Change project defaults

  • Change ant script $PROJECT/build.xml
    • Add property
<property name="birt.platform.dir" value="resources/WEB-INF/platform" />
    • Change war target:
...
<target name="war" depends="compile" description="Build the distribution .war file">             
...
    <copy todir="${war.dir}/WEB-INF/lib">
                        <fileset dir="${lib.dir}">
                                <include name="richfaces-impl*.jar" />
                                <include name="richfaces-ui*.jar" />
                                <include name="oscache*.jar" />
                                <include name="commons-digester.jar" />
                                <include name="commons-beanutils.jar" />
                                <include name="jsf-facelets.jar" />
                                <include name="jboss-seam-*.jar" />
                                <exclude name="jboss-seam-gen.jar" />
                                <!-- BIRT -->
                                <include name="com.ibm.icu_3.6.1.v20070906.jar" />
                                <include name="commons-cli-1.0.jar" />
                                <include name="coreapi.jar" />
                                <include name="dataadapterapi.jar" />
                                <include name="dteapi.jar" />
                                <include name="engineapi.jar" />
                                <include name="flute.jar" />
                                <include name="chartengineapi.jar" />
                                <include name="js.jar" />
                                <include name="modelapi.jar" />
                                <include name="modelodaapi.jar" />
                                <include name="odadesignapi.jar" />
                                <include name="org.apache.commons.codec_1.3.0.v200706111738.jar" />
                                <include name="org.eclipse.emf.common_2.2.1.v200702131851.jar" />
                                <include name="org.eclipse.emf.ecore.xmi_2.2.2.v200702131851.jar" />
                                <include name="org.eclipse.emf.ecore_2.2.2.v200702131851.jar" />
                                <include name="org.w3c.css.sac_1.3.0.v200706111724.jar" />
                                <include name="scriptapi.jar" />
                        </fileset>
                </copy>
                <copy todir="${war.dir}/WEB-INF/platform/">
                        <fileset dir="${birt.platform.dir}" />
                </copy>

build.xml all in one: Seam (BIRT) Recipe - $PROJECT/build.xml

Code Seam-BIRT servlet

  • Add BIRT pdf servlet to $PROJECT/resources/WEB-INF/web.xml .
....
  <!--  BIRT PDF servlet -->
   <servlet>
        <servlet-name>Document Store Servlet</servlet-name>
        <servlet-class>org.jboss.seam.pdf.birt.DocumentStoreServlet</servlet-class>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>Document Store Servlet</servlet-name>
        <url-pattern>*.pdf</url-pattern>
    </servlet-mapping>
...

Make BIRT report

  • make $PROJECT/view/sample.xhtml report (rptdesign)

Instantiate Seam component by

...
            <method name="open"><![CDATA[var reports = Packages.org.jboss.seam.Component.getInstance("sampleReportList", true);
            reportsIterator = reports.getResultList().listIterator();]]></method>
...

sample.xhtml all in one: Seam (BIRT) Recipe - Sample Report

...
<div class="actionButtons">
        <s:button id="done" 
               value="Create sampleReport"
                view="/sampleReport.xhtml"/>	
        <s:button id="report" value="Report" view="/sample.pdf?ReportName=report.rptdesign" />		  
</div>
...

Bon appetit

  • Run ant explode, start jBoss app. server
  • Cook in oven about 40 minutes & visit restaurant :-)

Seam app UI
Seam component in BIRT

Back to the top