spongyboss
spongyboss

Reputation: 291

Jasperreport without data source

How do I display a jasperreport without a datasource. The report is suppose to receive parameters from the java application and display them.

Upvotes: 9

Views: 8559

Answers (2)

Surendar S
Surendar S

Reputation: 123

You can call Jasper reports from Jasper server to your projects/websites by using Visualize.js concept.In this case you can pass your parameter from application to jasperreports and display it.

http://community.jaspersoft.com/project/visualizejs

Including Visualize.js file

 <script src="http:/(Your Jasperserver Domain):8080/jasperserver-pro/bif/visualize.js"></script>
 <div id="container" class="fill"></div>
 <div id="overlay" class="fill">
 <div id="ajax-icon" class="fill">
 <i class="icon-spinner icon-spin icon-3x"></i>
 <p>Loading...</p>
</div>
</div>  

Visualize.js part

BIF.init({
domain: 'http:/(Your Jasperserver Domain)/jasperserver-pro/',
username: 'jasperadmin',
password: 'jasperadmin',
mods: ['reports']
},function(Reports) {
mReport = Reports.open({
uri:'/public/Reports/Report1',
    container: document.getElementById('container'),
        inputParameters: {
        Id:'037e6b40-88e4-11e3-80d4-2673d3ec42cd',
        Range:100,
        ProfileId:'037des70-88e4-11e3-80d4-2673d3ec42cd',
        Theme:'test'
        },
   onReportFinished: function() {
        $('#overlay').hide();
    }
});           
});

Hope this will Help you!!!!

Upvotes: 0

GenericJon
GenericJon

Reputation: 8986

The way I would do it is to still put all of your text fields, etc. into the detail band, then use a new JREmptyDataSource(1) as your datasource. I.e:

filledReport = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource(1));

Passing the value 1 to the constructor will create a single virtual record in the datasource, so the detail band will be printed only once. I prefer this method as it means the report template is more similar to a normal report template. The alternative is to have a completely empty datasource and then put all of your content into a different band (e.g. column header).

Upvotes: 23

Related Questions