Custom Visualization Component Setup for JasperReports Server

Table of Contents 

This Wiki Page is a work in progress

Requirements

  1. JasperReports Server 5.6 or later (the custom visualization component requires JasperReports 5.6 to run)
  2. PhantomJS, a command line tool available for all the main operative systems (http://phantomjs.org/download.html)

Installation

  1. Configuring PhantomJS

    After downloading and installing phantomjs, be sure it works. Put it in the path, so it can be easily executed by the JVM. 

    The executable can be also specified by using the jasperreports property:

    com.jaspersoft.jasperreports.components.customvisualization.phantomjs.executable.path
  2. Installing the custom component Jar (if required)

    Add the jasperreports-customvisualization.jar into the WEB-INF/lib directory of your JasperReports Server web application (it should or will added to 6.x versions of the server)

  3. Configuring the JasperReports properties.

    The Custom Visualization Component requires a very simple configuration which consists in specifying where the require.js script is located (used for server side export only, like PDF) and allowing JasperReports Server to serve files from a specific package (like for other components like the JasperReports HighCharts custom component). This information is provided by setting two JasperReports properties inside the file jasperreports.properties. On the server this file is located at:

    <JRS installation directory>/apache-tomcat/webapps/jasperserver-pro/WEB-INF/classes/jasperreports.properties

    The two properties are:

    com.jaspersoft.jasperreports.components.customvisualization.require.js=file:///path/to/require.js
    net.sf.jasperreports.web.resource.pattern.customvisualization.scripts=com/jaspersoft/jasperreports/customvisualization/resources/require

    Replace /path/to/require.js with a proper absolute path to require.js. Please note that on Windows this path might just start with a letter (i.e. C:/path/to/require.js), while on the other systems, this should be prefixed by file://. This comes from a PhantomJS requirement when loading files from the local filesystem. However in testing Windows 7 the correct syntax was like com.jaspersoft.jasperreports.components.customvisualization.require.js=file:///C://appservers//apache-tomcat-7.0.22//tomcat-7.0.22_6.2.0//webapps//jasperserver-pro//optimized-scripts//bower_components//requirejs//require.js

    When working with Jaspersoft Studio, these two properties are automatically generated and added to the JasperReports properties handled by the designer, you can see them from the Preferences > Jaspersoft Studio > Properties.

    In the old version of the component, was required to specify the location of each javascript being used in your components, this is no longer necessary. In JasperReports Server all your scripts will be loaded inside the report unit as resources.

    The final requirement is of course the component itself. This is represented by a jar, that must be added to your classpath. The jar should be shipped with JasperReports Server, it is also shipped with Jaspersoft Studio.

  4. Finally Restart the server.

Igor Nesterenko

The Customer needs to run JS optimization after such setup, in other hand it can be broken in optimized mode

Reference

Feedback
randomness