The report viewer is the module of the JasperReports Server UI that displays JasperReports. It is a central part of the UI that users interact with frequently. In addition to displaying the report contents, the report viewer offers the following functionality:
• | Display input controls so that users may set report options, also called parameters. |
• | Let the user navigate through the pages of the report. |
• | Allow the user to export the report in various formats. |
Each of these is customizable; this allows you to control many details of the report viewing experience for your users. The input controls can be set either globally or on an individual report basis; the report viewer can be set globally. You can also add new export formats; see Adding Custom Export Channels.
Customizing Input Controls
The input controls are displayed in a form that gives the label of each form and the field or widget for the user to enter a value. The input fields and widgets, such as drop-down menus, radio buttons, and check boxes are determined by the input controls themselves, but their appearance can be customized with themes and their layout can be customized with a JSP file. For general information about input controls, refer to the JasperReports Server Administrator Guide.
Customizing the Input Controls Layout
JasperReports Server can display the input controls form in a pop-up window (the default), in a separate page, in a separate column, or at the top of the report page. Each kind of layout is determined by a JSP file that renders the input control page.
Layout Type | Files To Edit |
Pop-up window Separate page In page (left-hand panel) | <js-webapp>/WEB-INF/jsp/modules/inputControls/DefaultParametersForm.jsp <js-webapp>/WEB-INF/jsp/templates/inputControls.jsp |
Top of page | Inside <js-webapp>/WEB-INF/jsp/modules/viewReport/viewReport.jsp |
You can customize these files in one of two ways:
• | If you directly modify one or both of the files listed above and save them in the same location in your web application, your changes apply to all reports. The procedure is similar to Customizing JSP and JavaScript for the Login Page. After making your changes and redeploying the web app, every user would see your new input controls form. For example, to change the background color of all your input controls, you would modify these files. |
• | In the case of the file DefaultParametersForm.jsp, you can create a JSP file with a different name and use it in individual reports, without affecting the default appearance of input controls for other reports. |
Input controls were modified in 5.5. Custom input controls developed prior to 5.5 may require modifications in order to work with the new input control design. |
Once you have created the file you want, save the file in your server instance. For example, you could create a <js‑webapp>/WEB-INF/jsp/custom directory, and save your customizations there, for example as CustomShippingParametersForm.jsp.
JSP files rely on other JSP file to reuse parts of the user interface. In the file that you modify, you can either reference the default JSP helper files, or make copies of them to modify and reference instead. |
To use custom JSP input controls in a report, you need to add the JSP file to the report as a resource. For example, suppose the JSP for the input controls above was saved as <js-webapp>/WEB-INF/jsp/custom/customShippingParametersForm.jsp in your server instance. To attach this file to your shipping report, first locate the report in your repository and right-click to edit the JasperReport resource. Then go to the Controls and Resources page and set the Optional JSP location to the path of your file relative to <js-webapp>/WEB-INF/jsp/. In this example, you would enter custom/CustomShippingParametersForm.jsp.
Specifying a Custom JSP File for Input Controls |
For information about editing JasperReports in the repository, refer to the JasperReports Server User Guide.
Customizing the Report Viewer
The report viewer creates the page with the controls for paging through a report and exporting its contents in other formats. The main JSP files of the report viewer are:
<js-webapp>/WEB-INF/jsp/modules/viewReport/ViewReport.jsp
<js-webapp>/WEB-INF/jsp/modules/viewReport/DefaultJasperViewer.jsp
To change the report viewer, modify and save the default files without changing their names. The procedure would be similar to Customizing JSP and JavaScript for the Login Page. After redeploying the web app, your changes to the report view appear in every report for every user.
The following figure shows the default layout of the report viewer in 5.5:
The following figure shows a possible customization, using Spring Security tags to hide the refresh button after the timestamp from non-administrative users.
Possible Customization of the Report Viewer |
Other customizations could include limiting the number of export options and/or replacing the export menu with icons.
Recommended Comments
There are no comments to display.