Pages

Showing posts with label spring. Show all posts
Showing posts with label spring. Show all posts

Thursday, 18 October 2012

Birt Integration With Web Application Part2

Birt Integration Part1
Birt Integration Part2



Javascript for loading report using ajax:

         report.js is used for loading and downloading report using ajax.Js files are  located in /WebContent/js/  which also includes jquery-1.7.1.js.

         report.js has two functions:         
  • generateReport(rptdesignDocName):This loades report in center div.
  • downloadReport(format): Download current report in selected format.

     report.js code:
    
/**
 * This js contains two method 
 * 1)generateReport(reportName) : Requesting to load the report content in div.
 * 2)downloadReport(format): Downloading the current report in given format.
 */


//this will hold the currently loaded report name.
currentReportName="";
 /**
  * This method is responsible for loading the reports in the report div.
  * @param localReportName
  */
 function generateReport(reportName) {
 
  // here relative url is given if relative url is not working try giving full url
  var reporturl ="/BirtIntegration/loadReport?ReportName="+reportName+"&ReportFormat=html";
  
  $("#reportData").html("Loading...
");
  
        $('#reportData').load(reporturl ,function(response, status, xhr) {
         
          if (status == "error") {
      var msg = "Sorry but there was an error getting details ! ";
   $("#reportData").html(msg + xhr.status + " " + xhr.statusText);
    }
     });
        
        currentReportName=reportName;
 }
 
 /**
  * Download report function
  * 
  * @param format
  */
 function downloadReport(format){
  
  if(currentReportName==""){
   alert("Please Select the report.");
   return;
  }
  //here relative url is given if relative url is not working try giving full url
  var reporturl ="/BirtIntegration/loadReport?ReportName="+currentReportName+"&ReportFormat="+format;
  window.location.href = reporturl;
  
 }


Pagination Functionality (Under Development)

  The reports can have table which may have many number of rows,In such cases birt provides facility of loading particular page in their api. In a source of example project his part is partly implemented.I currently working one example having pagination in the report.



Download Birt Integration Sample Project

Downloads : BirtIntergration.zip
 (Note*: After downloading project copy jar from birt runtime lib to /WEB-INF/lib and refactor code as per your need.)


Update :Download below project for pagination support:

Downloads : Birt Example with pagination support

Note* : Purpose of this example is to understand how to integrate Birt engine in code. Please understand and improve as per your need. Do not use directly in production.