Customizing JavaScript Files and Optimize in Jaspersoft Reports Server

Posted on by By Ramu Vudugula, in Jaspersoft | 0

The JavaScript files are optimized to improve performance in jasper server. If you customize any JavaScript files, you need to download the optimization tools, optimize the files and restart JasperReports Server.

Inside the JasperReports Server web application, the JavaScript files are in the /scripts and /fusion folders.

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Get your 30 Days Trail Version

File names contain module and subcomponent names, for example /scripts/adhoc.start.js.

To optimize and implement custom JavaScript files:

For convenience, these steps assume that you place the JavaScript files from JasperReports Server and the scripts necessary to optimize them in a single Working directory.

You can place the files and scripts wherever you want but modify the paths accordingly.

  1. Create a working directory where you can copy JavaScript files and install and run the required scripts. In this example, the directory is called Working.
  2. Download and install node.js from http://nodejs.org/. Place the nodejs folder directly in your Working folder.
  3. Download r.js, a requirejs optimization file, from http://requirejs.org and place it directly in the Working folder
  4. Create a subdirectory inside nodejs folder for a copy of the JavaScript files from JasperReports Server. This directory is called js-sources.
  5. Copy the following directories from the JasperReports Server directory, , to js-sources:
    • Copy /scripts to js-sources/scripts.
    • Copy /fusion to js-sources/fusion
  6. Back up your js-sources directory.
  7. Create an optimized-scripts directory for the output of the optimization process.
  8. Back up your jasper server optimized-scripts directory.
  9. Open a command line tool and run the commands to optimize the JavaScript.
  10. In the following example is for Windows, it places the output in the optimized-scripts folder:

    % cd Working
    
    % nodejs\node r.js -o js-sources\scripts\build.js appDir=js-sources\scripts
    
    baseUrl=. optimize=uglify2 dir=optimized-scripts
    
  11. If you are using visualize.js, run the commands to optimize it.
    1. Open file Working/js-sources/scripts/build-visualize.js with text editor.
    2. Remove src/ from the following file paths:

      "mainConfigFile": "src/require.config.js",
      
      ...
      
      "startFile": "src/client/visualize.js.start.frag",
      
      "endFile": "src/client/visualize.js.end.frag"
    3. Save the file and close editor.
    4. Run the following command in the working folder:
    % nodejs\node r.js -o js-sources\scripts\build-visualize.jsout=optimized-scripts\client\visualize.js
    

    If you don’t find src/ in file Working/js-sources/scripts/build-visualize.js, then directly do the step C

  12. Copy the optimized scripts from your Working directory /optimized-scripts to Jasper Server /optimized-scripts
  13. Make data easy with Helical Insight.
    Helical Insight is the world’s best open source business intelligence tool.

    Lets Start 30 Days Free Trail

  14. Restart the Server

Now you can see the latest changes applied in scripts in jasper server

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

If you have any queries please get us at support@helicaltech.com

Thank You
Ramu Vudugula
Helical IT Solutions Pvt Ltd

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments