JasperReports JSF Plugin supports many of the data sources supported by the JasperReports engine and many others which don't need to be directly supported by Jasperreports. This is done through the jr:source component. Following is an example of how this component can be used. There are some issues that affect to each kind of data source, you should go forward to the documentation of the one you are planning to use if you need more information.
There are two ways of using the data source component. When only a report or report link is to be rendered in the same page you can include the report source component nested inside the report component. Following is an example:
<jr:reportFrame id="ordersReportFrame" ... > <jr:source ... /> </jr:reportFrame>
But, if you want to render more than one report frame or link, you can define the report source somewhere in the page and specify the id attribute. Then, the report component must reference the id of the source using the source attribute:
<jr:source id="mySource" ... /> ... <jr:reportLink id="orderReportLink" source="mySource" ... /> <jr:reportLink id="customerReportLink" source="mySource" ... />
Note: The report source component and the report component must be inside the same javax.faces.component.NamingContainer component instance.
There are many different report sources with different behavior depending on the selected type. Apart from that, all kind of report sources share a common set of attributes and, depending on the values of these common attributes, the report source component will behave different.
Note: All of these attributes support value expressions.
|type||The type of the report source used to load the report data.|
|query||Query string used to filter the data comming from the report source.|
|value||Each report source interprets this attribute in a different manner. Consult the documentation of each report source for details.|
Following is a table of the current available report sources and the value that must be used for the type attribute of the data source component.
|JNDI Report Source||jndi|
|JDBC Report Source||jdbc|
|CSV Report Source||csv|
|XML Report Source||xml|
|XLS Report Source||xls|
|Other Supported Sources||other|
If no value is set to the type attribute no data will be injected into the generated report.
There is no mandatory requirement to have a jr:source component to provide a report instance with data to be rendered. We can bind the report component (frame, link, subreport) directly to a managed bean property which offers a valid source object using the source attribute.
Following are the valid types supported by the source attribute at current date. You can also provide your own source types but you will need also to provide your own SourceFactory and Filler implementations in order to be fully supported by the renderers.