General terms

What is a "datasource"?

Datasource is a connection to an external system, such as a JDBC connection for example.
Datasource is created on the editor level and is not connected with any particular report. These settings are saved in the workspace and will be automatically restored after restart.

You can create any number of datasources but the only one, so called active datasource, can be used for the preview at the moment.

What is a "dataset query" ?

Dataset query is a description of data to be retrieved. SQL queries are the ones most often used.JasperWave also supports Xpath.

Can I add my own datasource?

Yes.JasperWave is built on the Eclipse platform and provides standard mechanizm to add your own data source via extension point.
Everything what you need is to create a new plug-in where to implement com.jasperwave.designer.datasource extension point.

Can I add my own dataset query ?

Unfortunatelly no. JasperReports supports only two types of quesies - SQL and Xpath - which are already implemented by JasperWave
There is no way to customize query wizards.

Supported Data Sources

What data sources does JasperWave support?

JasperWave supports the following data sources:

  1. JDBC - any DB with JDBC connection, SQL is used to specify columns
  2. XML - XML files or streams, XPath syntax is used to specify columns.
  3. CSV - accessing flat file data using standard delimiters, first row(header) might be used to define columns
  4. JasperReports - custom data source which implements JRDatasource interface
  5. JavaBeans - custom data source to get data from Plain Old Java Object
  6. Excel - accessing Microsoft Excel files, first row might be used to specify columns
  7. Empty - default data source for testing purposes, emulates predefined number of records

How to create the new datasource ?

On the main toolbar there is a combobox with available datasources. On the right, there is a button to open datasource manager dialog.

JasperWave: Data Source buton on the toolbar


Within the dialog, you are able to:

  • create a new datasource from the scratch
  • create a new datasource based on the existing one
  • edit datasource
  • remove datasource
  • make datasource active


JasperWave: Data Sources

JasperWave supports a wide variety of sources


JasperWave: Data Source wizard

How to make the datasource "active" ?

There are three ways to make the datasource active

  1. Select the checkbox for the required datasource.

    JasperWave: active Data Source

  2. Select the datasource from the combobox on the main toolbar
  3. Select the datasource from the combobox in Dataset Query Editor

How to configure the JDBC datasource ?

See Getting Started: Create JDBC data sourcefor detailed instructions.

How to configure the XML data source ?

JasperWave: XML data source settings

XML datasource implementation allows to access the data from a xml document using XPath expressions.

The data source is constructed around a node set (record set) selected by an XPath expression from the xml document.
Each field can provide an additional XPath expresion that will be used to select its value.
This expression must be specified using the "fieldDescription" element of the field.
The expression is evaluated in the context of the current node thus the expression should be relative to the current node.

How to configure the CSV data source ?

JasperWave: CSV flat file

This datasource implementation reads a CSV stream.
Datasource rows are separated by a record delimiter string and fields inside a row are separated by a field delimiter character. Fields containing delimiter characters can be placed inside quotes. If fields contain quotes themselves, these are duplicated (example: "John ""Doe""" will be displayed as John "Doe").

Since CSV does not specify column names, the default naming convention is to name report fields COLUMN_x and map each column with the field found at index x in each row (these indices start with 0). To avoid this situation, users can either specify a collection of column names or set a flag to read the column names from the first row of the CSV file.

Hints and tips:

  • When you change the fields delimiter, the editor automatically reads the source,
    separate fields according new delimiter and show the result (firsr 4 records) in Data Preview tab
  • If you select "use first row as a header", you will be able to use "Extract column names".
    Columns names will be read from the first row of the source file.

After finish, you have a chance to edit any data using inline editor


JasperWave: CSV datasource

Notice the button Report Fields which opens the dialog to setup correspondance between CSV datasource columns and report fields.
You can convert  columns to report fields and update the report templates by adding these fields

JasperWave: CSV datasource

How to configure the Excel data source ?

JasperWave: Excel Data Source

This data source implementation reads an XLS stream.

The default naming convention is to name report fields COLUMN_x and map each column with the field found at index x in each row (these indices start with 0).To avoid this situation, users can either specify a collection of column names or set a flag to read the column names from the first row of the XLS file.

NOTICE: the pricnciple of work with Excel datasource - "use first rowas a header", inline editor, Report Fields - is totally the same with CSV datasource.

How to configure the JasperReports data source ?

JasperWave: custom JasperReports Data Source

JRDataSource

This interface represents the abstract representation of a JasperReports data source. All data source types must implement this interface.
JasperReports provides default implementations of result set, bean collections and bean arrays data sources.

JRDataSourceProvider

Abstracts the means of creating and disposing a data source. This interface is meant to be the standard way to plug custom data sources into UI designers. Typically the report developer will implement this interface to create and return a configured data source of the desired type and then configure the designer to use this implementation.

The following example demonstrates a provider for a JRBeanCollectionDataSource.

 public class MyBeansDataSource extends JRAbstractBeanDataSourceProvider {

public MyBeansDataSource() {
super(PersonBean.class);
}

public JRDataSource create(JasperReport report) throws JRException {
ArrayList list = new ArrayList();
list.add(new PersonBean("Teodor"));
list.add(new PersonBean("Peter"));
return new JRBeanCollectionDataSource(list);
}

public void dispose(JRDataSource dataSource) throws JRException {
// nothing to dispose
}
}

How to configure the POJO data source ?

JasperWave: JavaBeans Data Source

There are two data source implementations that can wrap collections or arrays of JavaBean objects. Both implementations rely on Java reflection to retrieve report field data from the JavaBean objects wrapped inside the data sources. These data sources can be used to generate reports using data already available in-memory in the form of EJBs, Hibernate, JDO objects, or even POJOs.

The JRBeanArrayDataSource is for wrapping an array of JavaBean objects to use for filling a report with data, and the JRBeanCollectionDataSource is for wrapping a collection of JavaBeans. Each object inside the array or the collection will be seen as one record in this type of data source.

The mapping between a particular JavaBean property and the corresponding report field is made by naming conventions. The name of the report field must be the same as the name of the JavaBean property as specified by the JavaBeans specifications. For instance, to retrieve the value of a report field named address, the program will try to call through reflection a method called getAddress() on the current JavaBean object.

Nested JavaBeans properties can be also accessed in a JavaBean data source. For example, if the current JavaBean object inside the data source is of type Product and contains nested supplier information accessible by calling the getSupplier() method, which returns a Supplier object. In this case, to access the address property inside the Supplier object, a report field named supplier.address is required.

How to configure the Empty data source ?

JasperWave: Empty data source

A simple data source implementation that simulates a data source with a given number of virtual records inside.
It is called empty data source because even though it has one or more records inside, all the report fields are null for all the virtual records of the data source.

Supported Dataset Queries

What dataset queries are supported ?

Current version of JasperReports supports two types of queries - SQL and XPath. JasperWave provides two solid wizards for both

How to edit dataset query ?

Use double-click on Dataset query item withiin Data Explorer view in order to open dataset editor

JasperWave: New Data Set query

How to create the subdataset ?

Open context menu in Data Explorer view and select Subdataset item

JasperWave: new sub data set

How to design SQL dataset query ?

JasperWave: SQL query

First of all, you should have correctly defined active datasource and datasource type should be the same with dataset type.

In our case, for the SQL dataset we have active datasource of SQL type.

There are a few buttons on the right:

  • Run SQL
    executes SQL and shows first 100 records in Output data tab
  • Fields
    runs SQL with active datasource, gets result set, reads columns (name,type) from the result set and updates fields in the Fields tab
  • Wizard
    runs the visual SQL builder to design the SQL query. Visual builder doesn't support reverse engineering and each time starts from a scratch.
  • Load
    load SQL query from file in file system
  • Save
    save SQL query to file in file system

For queries which contain parameters with property Prompt, parameter prompt dialog will be opened before the execution.

How to design XML dataset query ?

JasperWave: XML Query

  1. XML document structure
  2. If you selected the correct datasource, in our case XML, you can press Get structure button. Editor handles the document and presents it in a tree. Tree supports Drag and Drop to create simple XPath expressions and report fields

  3. XPath query
  4. For simple XPath queries you can use Drag and Drop provided by structure tree. For more complex requests, you need to edit queries by yourself

    Generally the full power of XPath expression is available. As an example, "/A/B[@id > 0"] will select all the nodes of type /A/B having the id greater than 0.

  5. Run Xpath query
  6. Button to execute the XPath query. Very simple and useful tool to check the correctness of your Xpath expression

  7. Selected nodes
  8. Nodes (record set) selected by an XPath expression from the xml document

  9. Report fields
  10. You can use Drag and Drop provided by structure tree to create report fields or create them in regular way with button Add

Dataset Parameters

How can I use a data set parameter with an SQL query ?

In order to use parameters for you SQL, you should follow the standard format of the report parameters - $P{ParameterName}.

In the example below, you can see that two parameters are used in the SQL - one existing (MaxOrderId) and one new (myNewParam).

JasperWave: SQL parameters

When you press "Run SQL", the parameter prompt dialog will be opened.

For the existing parameter, you have to enter the correct value only, for the new one you should specify type class as well. After that, new parameter automatically will be saved in the list and later might be added to the list of report parameters

JasperWave: prompt parameters

How can I use a data set parameter with an XPath query ?

XPath query editor doesn't support parameters in XPath expressions.
It doesn't mean that you cannot use them,, you just should handle them by hands.

Report Preview

How it works ?

In order to preview the report, the editor performs the following steps:

  1. Check that there is an active data source. If no, the appropriate information dialog will be opened and then you will return on the design page
  2. Validate report parameters and check that all parameter type classes are in classpath.
  3. Check parameters  which should be prompted and generate dynamic prompt dialog

  4. JasperWave: report parameters prompt

  5.   Generate the preview and check that  this preview is not empty.

There are a lot of empty pages when I use an Excel data source. What happened ?

It is a bug of JasperReports engine which cannot be fixed by us




To be continued...

One of the most best-known is Viagra. What people talk about how to buy Viagra online reviews? Like all other drugs, Viagra is classified according of it's active ingredient. The most joint sexual problems in men are erectile dysfunction and enclosed sexual wish. Impotence can be the first sign of severe psychologic problem. Unhealthy lifestyle choices, venous leak, gemma diseases, and several medicaments can reduce your desire. Realizing what underlying stressors may exist is the first step in treatment. While the medication is credited with improving nausea, it may also cause sexual dysfunction.

Free Download

You can try JasperWave Report Designer free for a 30-day trial and see if it is right for you.

Try Now

Buy Now

Purchase a one year subscription to JasperWave Report Designer. Contact us for more information.

Buy Now

Go to top