# Web Reports

JReport provides the web reporting solution which is aimed at easier and faster report creation and design, faster report execution, easier customization, and better presentation style using a newer Rich Internet Application (RIA) Web 2.0 interface. A web report contains only one report and uses .wls as the file suffix.

The data sources that can be used to create web reports are business views that are resources built on top of queries. In JReport Designer, you can create web reports based on business views, and publish them to JReport Server. JReport Designer supports opening, creating, and editing of web reports.

In JReport Server, end users can create web reports via the Web Report Wizard using a browser and open and edit web reports via Web Report Studio (for details, see the Web Report Studio chapter in the JReport Server User's Guide). Web reports created in JReport Server can also be downloaded to JReport Designer for editing.

Pick a task from the following:

- Components supported in web reports
- Creating a web report
- Editing a web report
- Using dynamic resources in a web report
- Using local parameters in a web report
- Using formulas to control showing or hiding components
- Previewing a web report
- Saving a web report
- Opening a web report

Notes:

- A JReport Live license for JReport Designer is required in order to create web reports and use all the related features. If you do not have the license, contact your Jinfonet Software account manager to obtain it.
- The resources, components, properties and options that are not supported by web reports are not enabled on the user interface.

## Components supported in web reports

Components are the objects that you can place in a report. JReport provides a full set of components that allow you to present and control the report data and presentation in a wide variety of ways.

Web reports support the following report components:

- Tables
- Crosstabs
- 2-D charts
- Tabular
- Labels
- Images
- DBFields
- Formulas
- Summaries
- Parameters
- Special fields

  You can insert all special fields into web reports in JReport Designer. However, due to the characteristics of Web Report Studio, only these can be rendered and edited in Web Report Studio: User Name, Modified Date, Modified Time, Fetch Date, Fetch Time, Print Date, and Print Time.

- Multimedia objects
- Four web controls: parameter control, parameter form control, filter control, and navigation control.

## Creating a web report

To create a web report:

1. Click File > New > Web Report on the menu bar.
2. A blank web report with a tabular of one cell is displayed. You can then split the tabular, insert components to the tabular cells, and modify the component properties if required. For details, see the corresponding topics about the specific component in the Components chapter.

## Editing a web report

After a web report is built up, you can further modify it the same as you do with page report. For details, see Editing a page report.

## Using dynamic resources in a web report

When working with a web report, sometimes you may find that the view elements that have been predefined in the business view the web report uses cannot meet your requirements, in which case, you can create some dynamic resources and use them in the report to get the desired data. Then when you save the web report, the dynamic resources will be saved along with it as its resources.

Dynamic resources are report level resources, which means they are only available to the report for which they are created.

Dynamic resources that can be used in web reports include formulas and aggregations, and their usage in web reports is the same as that in library components. For details about how to use them, refer to Using dynamic resources in a library component.

## Using local parameters in a web report

When working with a web report, sometimes you may find that the predefined parameters in the catalog cannot meet your requirements, in which case, you can create some local parameters and use them in the report to get the desired data. Then when you save the web report, the local parameters will be saved along with it as its resources.

Local parameters are report level resources, which means they are only available to the report for which they are created. The usage in web reports is the same as that in library components. For details about how to use them, refer to Using local parameters in a library component.

## Using formulas to control showing or hiding components

The Invisible property of the objects in a web report can be controlled by a formula. For details about how to use formulas to control object properties, click here.

However, for any object whose parent doesn't have a data source, for example, a label in the tabular cell of a web report, if you want to use a formula to control its Invisible property, you need to first bind a business view to the web report, then you can create formulas of Boolean type based on this business view to control the property.

To bind a data source to a web report:

1. Click Edit > Bind Data on the menu bar. The Bind Data dialog appears. See the dialog.

2. Select a business view in the current catalog.
3. Click OK to bind the business view to the web report.

After binding the data source, you can now create formulas in this business view to control the Invisible property of objects in the web report, whose parents don't have data source. To do this:

1. Select the object and find its Invisible property in the Report Inspector.
2. Click in the value cell of the Invisible property and select the <Create Formula...> item from the drop-down list.
3. In the Input Formula Name dialog, specify the name of the formula and click OK. The Formula Editor appears.
4. Create the formula according to your requirement. You need to specify whether the formula is used as Group, Detail, or Aggregation by setting the Use As option on the toolbar.
5. Save the formula and exit the Formula Editor.
6. The formula name is now displayed in the value cell of the Invisible property.

   Then at runtime, whether the object is shown or hidden will be determined by the return value of the formula. A return value of true will hide the component.

The formula you created on the bound data source will be regarded as a dynamic formula in the selected business view, and you can find it in the Dynamic Resources > Formulas node of the Resource View panel. So there is another way to create formulas in the business view and use it directly when editing the Invisible property. To do this:

1. Click any blank area in the report body. The business view bound to the web report will be displayed in the Resource View panel.
2. Expand the Dynamic Resources > Formulas node, click <Add Formula…>, then create the formula as required.
3. Edit the Invisible property of the desired object, click in the value cell and you will find the formula is listed in the drop-down list.

## Previewing a web report

To preview a web report, do either of the following:

- Click View > Preview As > Web Report Result on the menu bar.
- Click the Preview As button on the Standard toolbar and then select Web Report Result.

The web report will then be opened in Web Report Studio. You can also click the View tab directly to preview the web report in JReport format, or select other format from the Preview As submenu to display it in that format.

Moreover, when previewing a web report, if it is developed with National Language Support, you can specify the language in which you want the report to display; if it contains parameters, you will be prompted to specify values for the parameters in the Enter Parameter Values dialog.

Notes:

- The function of previewing a web report in Web Report Studio also requires that:
  - You have checked the option Server for Previewing Reports when installing JReport Designer.
  - You have a JReport Live license for your JReport Server.
- The preview server is a web ad hoc disabled server, and it supports only one user and one report concurrently. Therefore, when you close the report you are previewing, you should use the exit button of Web Report Studio instead of the browser's. In this way, you can release the user session you occupy at the same time, so that you are able to previewing another report later.
- JReport Designer and the preview server are running in two separate JVMs. The preview server applies `-Djreport.url.encoding=UTF-8` in the startup batch file and this setting covers URL encoding/decoding. Therefore, when you preview a web report in Web Report Studio, if the name of the report or catalog file contains non-Latin characters, you need to add `-Djreport.url.encoding=UTF-8` into the startup batch file of JReport Designer as well; otherwise the preview will fail.
- When previewing a web report in Web Report Studio,
  - Make sure the JDBC driver's class path has been appended to setenv.bat in `<install_root>\server\bin.`
  - If the report contains some user defined data sources (UDS), you can use the classes you have compiled for using in Designer, but remember to append the classes to the class path of JRServer.bat in `<install_root>\server\bin`.

## Saving a web report

To save a web report, click File > Save on the menu bar, or the Save button on the Standard toolbar. This operation can also be accomplished by pressing the Ctrl + S keys. If the web report to be saved is new, the Save Report As dialog will appear for you to input a name.

To save a web report with a different name in the current directory:

1. Click File > Save As on the menu bar.
2. In the Save Report As dialog, type a new file name in the Report Name field.
3. The web report file type Web Report (*.wls) is the only default value in the Report of Type drop-down list.
4. Click Save to save the web report with the new name.

To save a web report to a different catalog, refer to Saving a page report to a different catalog.

## Opening a web report

To open a web report:

1. Click File > Open on the menu bar, or the Open button on the Standard toolbar.
2. In the Open Report dialog, browse to find the catalog that contains the web report you want to open.
3. In the Reports tab, select Web Report (*.wls) from the Report of Type drop-down list.
4. All the web reports in the current catalog will be displayed. Select the desired web reports.

   If you want to open web reports that you have opened recently, switch to the Recent tab, and then select the web reports you want to open.

5. Click Open to open the web reports that you specified.

Tip: If you just want to access some recently open web reports, click File > Open Recent and then select the web reports one by one from the submenu.