The connected library in CVC does not work.

JasperReports server 8.0.0
Jaspersoft studio 6.20.0

Connected the jQuery v3.5.0 libraries and https://github.com/vitmalina/w2ui/tree/w2ui-1.5.
Created cvc.
Completed the compilation build.js
It works in Jaspersoft studio.
I export it to the server, but it doesn't work here, the plug-in library w2ui is not added.

The problem is adding the wrapper:

wrap: {
        start: "(function(root){\n\nvar define = root.define;\n\n",
        end: "\n\n}(typeof __visualize__ != 'undefined' ? __visualize__ : (typeof __jrio__ != 'undefined' ? __jrio__ : window)));"
    },      
If add this wrapper, it will not work in Jaspersoft studio and JasperReports Server.

If the wrapper is not added, it will only work in Jaspersoft studio.


  build.js:

({
    baseUrl: '',
    optimize: 'none',
    paths: {
            'jquery': 'jquery350min',
            'w2': 'w2ui-1.5.min',
            'custom': 'custom'
    },
    optimizeCss: 'standard.keepLines',
    keepAmdefine: true,
    wrap: {
        start: "(function(root){\n\nvar define = root.define;\n\n",
        end: "\n\n}(typeof __visualize__ != 'undefined' ? __visualize__ : (typeof __jrio__ != 'undefined' ? __jrio__ : window)));"
    },        
    name: "custom",
    out: "custommin.js"
})
my module:

define('custom', ['jquery', 'w2'], function($) {
                
        var counter = 1;        
        return function (instanceData) {    
        
            const series = instanceData.series[0];
            const records = addRecid(series);
            const columns = createColumns(series); 
            creatediv(instanceData, instanceData.id, 'main');
         
            function creatediv(instanceData, elemntId, name) {
                const newDiv = document.createElement("div");
                newDiv.id = name;
                newDiv.style = "width: 100%; height: 100%;";        
                window.document.getElementById(elemntId).appendChild(newDiv);
            }
             
            function createColumns(records) {
                  const columns = [];
                  for (var key in records[0]) {
                    if (records[0].hasOwnProperty(key)) {
                        
                          columns.push({ field: key, text: key, size: '33%', sortable: true, searchable: true });
                    }
                  }
                  return columns;
            }
              
            function addRecid(records) {
                   const newrecords = [];
                   for (var i = 0; i < records.length; i++) {
                    const record = records[i];
                    record.recid = counter++;
                    newrecords.push(record);
                  }
                  return newrecords;
            }
            
            $(function () {
                $('#main').w2grid({
                name: 'grid',
                        show: {
                            toolbar: true,
                            toolbarDelete: true
                        },
                        columns: columns,
                        records: records
                });
            });    
        }
});

Attachments: 
archivestas's picture
Joined: Apr 10 2023 - 11:44pm
Last seen: 4 months 3 weeks ago

Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times.

mrajkuma - 5 months 1 day ago

2 Answers:

Hello,

Please try to use latest studio 8.x.x version and give try adding wrapper and check if it works in Jaspersoft studio.
Without wrapper added - What error you see in jasperserver.log file on JasperReports Server.
Looking at error log might help us to narrow down this.

jphadtar's picture
1532
Joined: Mar 20 2022 - 10:51pm
Last seen: 1 day 46 min ago

There are no server-side errors in the log file. Errors only when trying to use the functions of the connected libraries. I am applying 2 projects with different libraries. Errors manifest for w2ui. There are no errors for Grid, but it does not work properly.

Tested on versions of jaspersoft studio 6.20.0, 6.20.1, 6.20.3.

Tested on jasperreports server versions 8.0.0, 8.1.1.

Attachments: 
AttachmentSize
File jasperbug.rar1.03 MB
archivestas's picture
Joined: Apr 10 2023 - 11:44pm
Last seen: 4 months 3 weeks ago
Feedback
randomness