[#14621] - The connected library in CVC does not work.

Category:
Bug report
Priority:
High
Status:
New
Project: Severity:
Block
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

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
                });
            });    
        }
});

AttachmentSize
Binary Data custom_report.jrxml4.17 KB
v8.0.0
Custom Visualization Component
archivestas's picture
Joined: Apr 10 2023 - 11:44pm
Last seen: 2 weeks 2 days ago

4 Comments:

#1
AttachmentSize
File build.js462 bytes
#2
AttachmentSize
File custom.js1.35 KB
#3
AttachmentSize
File w2uimin.js436.26 KB
#4
Feedback