JBoss.orgCommunity Documentation

Chapter 2. Adding BIRT Functionality to Standard Seam Web Project

updated
2.1. Creating Seam Web Project with Birt Facet
2.2. Integration with Seam

In this chapter you'll know how to create a Seam web project with BIRT capabilities included.

You are supposed to have Seam runtime and JBoss Application Server downloaded and extracted somewhere on you hard drive.

Tip:

We usedJBoss Seam 2.0.1 GA and JBoss Application Server 4.2.2 GA in examples of this guide.

First, open Seam perspective by going to Window > Open Perspective > Other > Seam. To create a new Seam Web project follow to File > New > Seam Web Project (or File > New > Other > Seam > Seam Web Project if you are not in the Seam perspective).

On the first wizard page enter the project name, then specify the target runtime and target server. In the Configuration section click Modify to configure the project facets.


Choose the 2.0 version of the Seam facet and enable the Birt Reporting Runtime Component facet.


Or you can just choose the JBoss BIRT Integration Web Project configuration.


Next three pages are filled out with defaults, just leave them through by pressing Next. On the Seam Facet page you should specify the Seam runtime and Connection profile.


Hit Finish to create the project with Birt functionality enabled.

The JBoss BIRT Integration feature contains the BIRT tag that allows the user to add a BIRT report to an .xhtml file:

<p:birt xmlns:ui="http://java.sun.com/jsf/facelets" 
            xmlns:s="http://jboss.com/products/seam/taglib" 
            xmlns:p="http://jboss.com/products/seam/birt" 
            designType="run" 
            format="pdf" 
            designName="test.rptdesign" 
            title="JBoss Birt Test">
        
</p:birt>

Let's look how it works.

Create in the Web Content folder three .xhtml pages with the following content:

Now start the application server by clicking the Start option in the context menu of the server in the JBoss Server View (if the view isn't open go to Window > Show View > Other > JBoss Server View). Try the tests out by accessing http://localhost:8080/hellobirt/birttests.seam in your web browser.


Now if you click Test Birt you should see the following .pdf file:


After clicking Test Birt 1 the next page is displayed:


Put the test param as Sample Parameter value, specify the maximum possible Customer Number as 1001, for instance, and then press Ok. You'll see the following BIRT report:


The BIRT tag recognizes most of the parameters described on the BIRT Report Viewer Parameters page. The attributes of the BIRT tag don't contain the "__" prefix.

The param tag describes report parameters (see the listing for the testbirt.xhtml above). It supports the following attributes:

  • name - the parameter name (required)

  • value - the parameter value (required)

  • isnull - specifies that a report parameter has a null value (optional)

  • islocale - specifies whether the parameter is localized (optional)

These tags are defined in the org.jboss.birt.core/resources/jboss-seam-birt.jar library that contains source.

It is also possible to embed a BIRT report in some Seam .xhtml page. See how it may be done:

Example:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
		                 xmlns:s="http://jboss.com/products/seam/taglib" 
		                 xmlns:ui="http://java.sun.com/jsf/facelets" 
		                 xmlns:f="http://java.sun.com/jsf/core" 
		                 xmlns:h="http://java.sun.com/jsf/html" 
		                 xmlns:rich="http://richfaces.org/rich" 
		                 xmlns:b="http://jboss.com/products/seam/birt" 
		                 template="layout/template.xhtml">
        <ui:define name="body">
                <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
                     <rich:panel>
                         <f:facet name="header">Products</f:facet>
                         <b:birt designType="embed" designName="ProductCatalog.rptdesign" 
                                         embeddable="true" masterpage="false"/>
                             <div style="clear:both"/>
                     </rich:panel>
                     <div class="actionButtons">
                         <s:button view="/ProductsEdit.xhtml" id="edit" value="Edit"/>
                         
                         <s:button view="/#{empty productsFrom ? 'ProductsList' : productsFrom}.xhtml" 
                                             id="done" value="Done"/>
                     </div>
        </ui:define>
</ui:composition>

See the result in a Browser: