Pages

Tuesday, 16 October 2012

Birt Integration With Web Application




Birt Integration Part1
Birt Integration Part2

Birt is one of the powerful free report designing tool which comes with nice eclipse plugin having good report designing tool.
When I was designing reports with designer plugin in eclipse I found it very simple. But when it came to deployment we need to deploy it in separate web application provided by birt-runtime, but it was not the requirement for me.I was looking for birt integration with my existing application. So I started analysis for integrating birt report engine in my application and after 1 week of research I was successfully able to integrate with my application.
For better understanding I have created one simple web application.Go through following steps to achieve successful integration:



Index For Birt Integration
     1) Overview

     2) Installation

     3) Java Classes For integration

     4) Jsp and Sample Reports

     5) JavaScript for loading report using ajax.

     6) Sample report with pagination functionality (Under development).

     7) Download 





Overview


This simple birt integration web project which provides the same functionality provided by birt web application.Basic flow starts with ajax report request which is simply handled by one servlet and which is handover to report engine for processing and rendering output to the output response or downloading in pdf,xls and doc format.Note* Currently pagination feature is under progress.

Here we are using following technology:


  1. Birt 3.7.1 libs
  2. jquery-1.7.1.js (here any version will work as we are using for ajax call only)
  3. Simple servlet and jsp.
  4. Eclipse Plugin For Birt Report Designer.

Installation

         Follow below steps for installation of this example web project.

1) Download this example web project from here.
Update :Check sample project for pagination support here

2) Import the project in eclipse

3) Download birt 3.7.1 runtime or other version from here

4) Copy all the jars from birt-runtime-3_7_1\birt-runtime-3_7_1\ReportEngine\lib To web  

applications lib.

Java Classes For integration


These are the classes which are responsible for integrating birt engine in web application. These classes will simply instantiate ,initialise the report engine,process reports and destroy the engine when context is destroyed. 


Below is short description of the classes in sample web project:

1) BirtReportController : This class handles request for the report rendering or downloading.

2) ReportProcessor  : This is singleton class which takes care of starting report engine  ,processing report ,rendering report and shutting down report engine.

3) ReportRenderer : This class actually process reports and renders it to httpresponse object.It also handles downloading report functionality.

4) BirtEngineFactory : This class configures birt engine using EngineConfig class object and returns  

BirtEngine object.It has logging configuration.
.
5) ReportParameterConverter : Convert report parameter value between object and string.

Below is the source code of the some Class with explanation:

1) BirtReportController :

This class extends httpservlet which is responsible for handing report rendering request.

Method:


  • init() : Initialise birt engine
  • get() or post() : handles processing and downloading report request
  • destroy() :Shutdown report engine.


code:
package BirtIntegration.Controller;
 
   import java.io.IOException;
 
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import BirtIntegration.BirtViewer.ReportProcessor;
 
 
   public class BirtReportController extends HttpServlet {
 
         //this is the single tone class.
         private ReportProcessor processor ;
         
         
         @Override
         public void  init(){
          
               processor = ReportProcessor.getReportProcessor();
               processor.initilizeBirtEngine();
               System.out.println("Engine Initialized!!");
         }
         
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                     throws ServletException, IOException {
 
               processor.processReport(request, response);
System.out.println("processing report complete");
               
         }
         @Override
           public void doPost(HttpServletRequest request,
              HttpServletResponse response)
            throws ServletException, IOException {
                 doGet(request, response);
     }
         
         @Override
         public void  destroy(){
 
            processor.shutDownBirtEngine();
           
           
         }
         
   }


2) ReportProcessor  :

This is singleton class has BirtEngineFactory  and ReportRenderer object.

This class performs following operations using ReportRenderer:


  • Initializing Report Engine.
  • Processing report for rendering and downloading.
  • Destroying report engine.



Code:
   package BirtIntegration.BirtViewer;
 
   import java.io.File;
   import java.util.logging.Level;
 
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
 
   import BirtIntegration.factory.BirtEngineFactory;
 
   /**
 * This class is responsible for initlizing birt engine configuring birt  *engine,and processing and rendering reports.
    *
    */
   public class ReportProcessor {
 
         private BirtEngineFactory birtEngineFactory;
         private ReportRenderer reportRenderer;
         private static ReportProcessor reportProcessor =null;
         
         //private constructor for single tone object.
         private ReportProcessor(){
               
         }
         
         public boolean initilizeBirtEngine(){
               boolean isInitialized =true;
               reportRenderer = new ReportRenderer();
               reportRenderer.setBirtEngine( this.getBitEngineFactory().getEngine() );
               
               System.out.println("Bit Engine Successfully Started.");
               
               return isInitialized;
         }
         
         /**
          * Annotated with @ bean and will create BirtEngineFactory bean.
          * @return
          */
         private BirtEngineFactory getBitEngineFactory(){
               
               birtEngineFactory = birtEngineFactory = BirtEngineFactory.getBirtEngineFactory() ;
               //uncomment to use logging
               //birtEngineFactory.setLogLevel( Level.FINEST);
               //birt engine logs will be created under this directory.
               //currently this line is commented
               //birtEngineFactory.setLogDirectory( new File("E:/WorkSpaces/PracticeWorkspace/BirtIntegration/birtlogs"));
               
           return birtEngineFactory;
         }
         
 
         public void shutDownBirtEngine(){
               birtEngineFactory.destroy();
               
         }
         
         public void processReport(HttpServletRequest request,
          HttpServletResponse response) {
               reportRenderer.processReportDesignDocAndRenderReport(request, response);
         }
         
         public static ReportProcessor getReportProcessor() {
               if(reportProcessor !=null){
                     return reportProcessor;
               }
               reportProcessor = new ReportProcessor();
               return reportProcessor;
         }
         
   }

3) ReportRenderer

This class actually process the report request. This class has method processReportDesignDocAndRenderReport(request,response), the request object has following parameters :

  • ReportName :ReportName which is processed (e.g books_report.rptdesign).
  • ReportFormat : Html,Pdf,Xls,word. If it is other than html then it’s download request.
  • pageNumber  : This used to render particular page request in pagination.
  • Other Request Parameter in request object will be converted in report parameter ,which will be  given to query or other data sources as per the need.These parameters are used for filtering the reports data.

All the reports (.rptdesign ) are located in BirtIntegration\WebContent\Reports folder.


The report is processed in two phases by

1)IRunTask : Process .repdesign and generates temp.rptdocument and it also converts  

request parameter to report parameter.

2)IRenderTask : Processes temp.rptdocument document and renders report to response 

object based on type html,pdf,xls. It is responsible for setting the current page 
and also getting the total count of pages.

Code of processReportDesignDocAndRenderRepor() is below for whole class code download the example project :


code:


Code:
/**
    * This is overridden method which responsible for processing report  i.e .rptdesign document.and also rendering the report.
    * 
It also handles downloading the report.
    *
    */
   
   protected void processReportDesignDocAndRenderReport(HttpServletRequest request,
               HttpServletResponse response) {
         
         try{
               
         //get report name from request object.
         String reportName = request.getParameter( this.reportNameRequestParameter );
         
         //logger.info("Processing report:"+reportName);
         
         //get format in which we are going to render report i.e:html,pdf,excel
         String format = request.getParameter( this.reportFormatRequestParameter );
         
         //pagination handling
         String pageNumber = request.getParameter("pageNumber");
         int currentPageNumber=0;
         if(pageNumber!=null&&!pageNumber.equals(""))
         {
               currentPageNumber = Integer.valueOf(pageNumber);
               
         }
         
         //give the download report Name here.
         String downloadFileName = "MyReport";
         
         //Base URL
         String baseUrl = request.getScheme() + "://"  + request.getServerName() + ":"  + request.getServerPort()+request.getContextPath();
         
         ServletContext sc = request.getSession().getServletContext();
         if( format == null ){
               format="html";//default format
         }
         
         
         IReportRunnable runnable = null;
 
         //opend design document
         runnable = birtEngine.openReportDesign( sc.getRealPath("/Reports")+"/"+reportName );
         
         //first process the report using Iruntask which will create the temp.rptdocument
         IRunTask iRunTask = birtEngine.createRunTask(runnable);
   
         iRunTask.getAppContext().put( EngineConstants.APPCONTEXT_BIRT_VIEWER_HTTPSERVET_REQUEST, request );
         
         //put the parameter values from request to the report parameter
         iRunTask.setParameterValues(discoverAndSetParameters( runnable, request ));
         
         //create temp rpddocument
         iRunTask.run(sc.getRealPath("/Reports")+"/temp.rptdocument");
         iRunTask.close();
         
         
         //now do the rendering operation
         IReportDocument reportDoc = birtEngine.openReportDocument( sc.getRealPath("/Reports")+"/temp.rptdocument" );
         IRenderTask iRenderTask= birtEngine.createRenderTask(reportDoc);
         
         //set the format
         response.setContentType( birtEngine.getMIMEType( format ));
         IRenderOption options =  null == this.renderOptions ? new RenderOption() : this.renderOptions;
 
         //if html set html related options
         if( format.equalsIgnoreCase("html")){
               
               HTMLRenderOption htmlOptions = new HTMLRenderOption( options);
               htmlOptions.setOutputFormat("html");
               htmlOptions.setOutputStream(response.getOutputStream());
               htmlOptions.setImageHandler(new HTMLServerImageHandler());
               htmlOptions.setHtmlPagination(true);
               htmlOptions.setBaseImageURL(baseUrl+"/images");//TODO:Change from local host to actual path
               htmlOptions.setImageDirectory(sc.getRealPath("/images"));
               htmlOptions.setSupportedImageFormats("PNG");
               htmlOptions.setEmbeddable(true);
               
               
               iRenderTask.setRenderOption(htmlOptions);
 
               
               //if pdf set pdf related downloading options
         }else if( format.equalsIgnoreCase("pdf") ){
               
               PDFRenderOption pdfOptions = new PDFRenderOption( options );
               pdfOptions.setSupportedImageFormats("PNG;GIF;JPG;BMP");
               
               pdfOptions.setOutputFormat("pdf");
               pdfOptions.setImageHandler(new HTMLServerImageHandler());
               pdfOptions.setBaseURL(baseUrl);
               //pdfOptions.setOutputFileName("my.pdf");
               pdfOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW, IPDFRenderOption.FIT_TO_PAGE_SIZE);
               response.setHeader(  "Content-Disposition", "attachment; filename="+downloadFileName );
               pdfOptions.setOutputStream(response.getOutputStream());
               
               iRenderTask.setRenderOption(pdfOptions);
               
               
         //if XLS set XLS related downloading options
         }else if(format.equalsIgnoreCase("xls")){
               
                 EXCELRenderOption xlsOptions = new EXCELRenderOption(options);
                 xlsOptions.setOutputFormat("xls");
                 response.setHeader(   "Content-Disposition", "attachment; filename="+downloadFileName);
                 xlsOptions.setImageHandler(new HTMLServerImageHandler());
                 xlsOptions.setOutputStream(response.getOutputStream());
                 //xlsOptions.setOption(IRenderOption.EMITTER_ID, "org.uguess.birt.report.engine.emitter.xls");
                 xlsOptions.setOption(IRenderOption.EMITTER_ID, "org.eclipse.birt.report.engine.emitter.prototype.excel");
                 iRenderTask.setRenderOption(xlsOptions);
                 
         }else{
 
               response.setHeader(  "Content-Disposition", "attachment; filename=\"" + downloadFileName + "\"" );
               options.setOutputStream(response.getOutputStream());
               options.setOutputFormat(format);
               iRenderTask.setRenderOption(options);
               
         }
         
         /*
          * This is used for pagination and setting the page number we want to display
          */
         long pageCount = iRenderTask.getTotalPage();
         if(currentPageNumber!=0)
         {
               if(pageCount >=currentPageNumber){
                     iRenderTask.setPageNumber(currentPageNumber);
               }
         }
         //save the page count in session to use for pagination.  
         //using this page count we can implement pagination.
         request.getSession().setAttribute("pageCount", pageCount);
 
 
         //render report
         iRenderTask.render();
         //close task and doc
         iRenderTask.close();
         reportDoc.close();
         
         //logger.info("Processing report completed successfully:"+reportName);
         
         }catch (Exception e) {
               
               //logger.error("Exception while proceessing report ",e);
               e.printStackTrace();
         }
   }



BirtEngineFactory  and ReportParameterConverter classes are pretty straight forward.
Please click here to download source.
Jsp and Sample Reports



        There is one Reports.jsp located in /WebContent/jsp/Reports.jsp which used for handling report loading . This is simple jsp which has left navigation div and center div. When report is selected from the left navigation it will be loaded in center div and this is an ajax call for loading report.Also download option are above the center div which allows user to download report in pdf,xls and doc format. Screen shots of jsp is in below section.



I have created two sample reports. These reports are located in /WebContent/Reports directory.


  • First_Report.rptdesign (Hello World Report)

This is simple report contains one Hello world message and one image.


  • books_report.rptdesign

This report will show the details books in table and it will show pie chart of total price by book type below the table.This reports uses xml data source to load the details.The books.xml is located in /WebContent/ReportXmlDatasource/books.xml.

To locate the books.xml check the data source url is working by hitting test connection

as shown below. If it is not working then browse to the books.xm manually.
Currently url is :http://localhost:8080/BirtIntegration/ReportXmlDatasource/books.xml

Data Source window:

Screen Shot for Books Details Report:





























Visit below link for part2 and downloading example project:
Birt Integration With Web Application Part2

80 comments:

  1. This is a great example!
    As far as I tested, it does not work with Reports using Parameters.
    Would it be possible to show the Parameter options if Report contains parameters?
    Thanks!

    ReplyDelete
  2. Yes it is possible to send parameters to report.
    put the parameters in request with the same name as report parameter.

    ReplyDelete
  3. Hi Vikaram,
    Thanks a lot for the good example with enough explanation
    Is possible to enable web viewer in your example , if yes how it can be done
    Please clarify me.

    Thanks

    Barani Kumar

    ReplyDelete
  4. Hello Barani,

    This example demonstrate integration of Birt engine withing your web application i.e.it is a simple servlet project which configures and start birt engine using birt api.It will follow below steps for generating reports.
    1)When application context loads it will start birt engine.e.g tomcat start it will start engine
    2)Create .rptdesign doc and put in webapps or web-inf folder
    3)Make request from jsp/html page to .rptdesign with report parameters in request.
    4)This request will be handled by servlet which is having access to birt engine. Engine will process the .reptdesign and it will convert request parameters to report parameters.
    5)After processing report based on the output type it will render report e.g html,excel,pdf ,doc etc.

    So in this scenario you won't need the web viewer.

    Note*:you can easily implement pagination.

    Please go through the code for better understanding.

    ReplyDelete
  5. Hi Vikram,

    First of all let me thank you for such a brilliant effort. Can you plz be a bit more elaborate on passing report parameters with integration? Thing is that, when I preview the report from designer I see the parameter selection dialog coming up, however on integration I am not being able to do so and the report is being generated with the default values of the parameters.

    Thanks,
    Sutanu

    ReplyDelete
  6. Hi Vikram,

    How to sort table columns on client side(Using java script)


    Thanks
    Shridevi

    ReplyDelete
  7. You have to send the parameters in your HTTP request and the name of the form element should be same as the report name. e.g if your report parameter name is firstName then you should have input field with name="firstName" in your form or http://localhost:8080/loadUsersList?firstName="anonymous" in url.

    Possibly I will create example and post it soon.

    Thanks

    ReplyDelete
  8. Hey I am trying to run your sample project, when I click on any report mention on jsp I gets server error 500,what to do ?
    And also I want to pass some parameters in my report through jsp or web interface.How can I add ?

    ReplyDelete
  9. Hi Vikram

    Thanks for the wonderful post. I have tried the same and it is working fine.
    Only problem I had was when downloading the reports, it was downloading with the name 'MyReport' and without any extension. I had corrected that in ReportRenderer class.

    Now I don't know how to go ahead with pagination.. Do you have any steps what are all have to be done in the design, jsp etc..

    Thanks,
    Caroline

    ReplyDelete
  10. Hi Carollne,

    Below are the steps to implement pagination.
    1) open your report in eclipse report design perspective and go table properties and set Page Break Interval to 10 records per page or what ever you need.
    2)In class ReportRenderer go through processReportDesignDocAndRenderReport method you will see the pagination code with comments ,which is Already implemented you just need to modify or use it as it is.

    ReplyDelete
    Replies
    1. Hi Vikaram,

      Thanks a lot for your reply.

      I've tried yesterday exactly what you have mentioned in these steps.

      My problem is the report is paginated but all sections are displayed in the same page.

      I guess we have to implement the jsp part to list the page numbers, prev, back and write some code on the front end so that it will work..

      Anyway, I'll download your latest example and try and let you know.

      Thanks,
      Caroline

      Delete
    2. Hi Vikram

      It was working.. I've customized according to my need. Thanks a lot.

      Thanks,
      Caroline

      Delete
  11. I see that pagination is really troubling you guys. So I have implemented pagination.

    Please download sample project from "Birt Integration With Web Application Part2" i.e below link
    http://birtgrip.blogspot.in/2012/10/birt-integration-with-web-application-part2.html

    Thanks,
    Vikram

    ReplyDelete
  12. Hello,Vikram i have try to load report using spring MVC.
    I hva used your code to process parameter and for all other stuff.
    but wen i requesting for report it throws Exception
    java.lang.ClassNotFoundException: org.eclipse.birt.report.engine.api.IRenderOption
    I have bind all jar of birt run time.

    ReplyDelete
    Replies
    1. please make sure that all jars are in classpath. if you are using maven please check below link for maven dependancies for birt:
      http://birtgrip.blogspot.in/2012/10/maven-dependency-for-birt.html

      Delete
  13. Hi Vikram,

    First of all, let me thank you for this brilliant example.
    None of the documents in Eclipse narrates such a brilliant working example.

    However, I am unable to actually run this in my system. Can you please give me few lines on how to set this up in eclipse ?

    Thanks
    Mangalam

    ReplyDelete
  14. Hi Mangalam,

    Please check above installation section.

    Thanks,
    Vikram

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Hi Vikram,

      Thanks for the post.

      I have downloaded pagination project and imported in eclipse. Followed as per the instruction. But i am not able to run. When I click on Hello world report or Book detail report I get class not found exception. Can you help me on this:

      java.lang.NoClassDefFoundError: org/eclipse/birt/report/engine/api/IRenderOption
      at BirtIntegration.BirtViewer.ReportProcessor.initilizeBirtEngine(ReportProcessor.java:28)
      at BirtIntegration.Controller.BirtReportController.init(BirtReportController.java:23)
      at javax.servlet.GenericServlet.init(GenericServlet.java:160)


      ================and =========================================================

      aused by: java.lang.ClassNotFoundException: org.eclipse.birt.report.engine.api.IRenderOption
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)


      Delete
    4. Hi Krishna,

      Copy the reportengine/lib contents(jar files) and paste them in Projectname-->WebContent-->WEB-INF-->lib folder in eclipse.

      Check if it helps. I also got the same error and resolved this way.

      Thanks,
      Anshuman

      Delete
  15. Hi Vikram,

    Thanks once again for the wonderful example. I am sure this is one of the best working and practical example available (after a week of searching for proper examples) :)

    However, I am just a week old with BIRT and not very familar with the concepts. Is it possible for you to elaborate the above example in a little more elaborate manner?

    Also w.r.t parameters being passed to BIRT (from JSP to .rptdesign files) , if you could post a small example it would be great.

    You may also reach me on mangalam.singhania1285@gmail.com

    Thanks
    Mangalam

    ReplyDelete
  16. Hi I am trying to send the parameter in my report so to pass it ? do I need to add this parameter in url of report ?help..
    And also I made a report with jdbc which is showing only one page in the html output as well as in downloaded one.how to resolve it ?
    Thanks

    ReplyDelete
  17. HI vikarm,
    Can you please help me oue I got stuck,I need to pass some parameters in my report through jsp page,can you help me out what exact steps I need to do.
    Thanks in advance.

    ReplyDelete
    Replies
    1. if your report parameter name is say "name"
      then pass name value in url e.g as "http://localhost:8080/report?name=chhabra"
      i.e pass your report parameter values as form parameter.

      I have already explained this above.

      Delete
  18. How do we evaluate whether the generated report has data in it.
    Below is my code

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public void generateReport(String fileName, String destinationPath,String reportType, String paramValue) {
    //Variables used to control BIRT Engine instance
    EngineConfig conf = null;
    ReportEngine eng = null;
    IReportRunnable design = null;
    IRunAndRenderTask task = null;
    HTMLRenderContext renderContext = null;
    HashMap contextMap = null;
    HTMLRenderOption options = null;

    conf = new EngineConfig();
    // conf.setEngineHome("C:/birt-runtime-3_7_2/ReportEngine");
    conf.setEngineHome(System.getProperty("BIRT_HOME"));

    eng = new ReportEngine( conf );

    try {
    design = eng.openReportDesign(PropertyResolver.ReadProperty("INPUT_LOCATION") + fileName);
    } catch (Exception e) {
    System.err.println("An error occured during the opening of the report file!");
    e.printStackTrace();
    System.exit(-1);
    }

    task = eng.createRunAndRenderTask(design);

    renderContext = new HTMLRenderContext();
    renderContext.setImageDirectory("image");
    contextMap = new HashMap();
    contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
    task.setAppContext( contextMap );
    task.setParameterValue("reporttype", reportType);
    task.setParameterValue("paramval", paramValue);

    options = new HTMLRenderOption();
    options.setOutputFileName(PropertyResolver.ReadProperty("OUTPUT_LOCATION") + destinationPath +".pdf");
    options.setOutputFormat("pdf");
    task.setRenderOption(options);


    try {
    task.run();

    } catch (Exception e) {
    System.err.println("An error occured while running the report!");
    e.printStackTrace();
    System.exit(-1);
    }

    //Yeah, we finished. Now destroy the engine and let the garbage collector
    //do its thing
    System.out.println("All went well. Closing program!");
    eng.destroy();
    }

    ReplyDelete
    Replies
    1. I think you can do this in report designer when designing report.
      You can use script there.
      Check below link for report scripting :
      http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php

      Delete
  19. Hello,

    I have the following

    1).rptdesign file
    2)a eclipse dynamic webproject(not a eclipse report project) where i kept the .rptdesign in Reports folder
    3)then i created a simple java file in the web project which uses the birt report engine api to generate report as xls.
    4)i put all the runtime libs from birt runtime folder into my webtier/webinf/libs
    5)after running the java file an empty excel file is created.
    with the below error on console at LINE:

    org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
    SEVERE: Error happened while running the report.
    java.lang.NoClassDefFoundError: org/eclipse/datatools/connectivity/oda/profile/OdaProfileExplorer
    at org.eclipse.birt.report.data.oda.jdbc.dbprofile.impl.Connection.loadProfileFromProperties(Connection.java:186)

    ReplyDelete
    Replies
    1. Could you please provide more information ?

      Delete
  20. i had gone through your example my questions are as follows:
    1.i had downloaded birtwebviewer which consist of one the example report test.
    which has in built paging and button to import in any format so how can i integrate same as your project or is there any other way plz help me out

    ReplyDelete
  21. Hi Vikram,

    Once again thanks a lot for all your efforts. I have one more doubt in this integration.

    The requirement is to show the data in html format, without pagination.

    I can show that, but the master page and headers are repeated.

    How to remove the Master page and the header in all the pages except first page?

    Please let me know your views on this.

    Thanks
    Caroline

    ReplyDelete
    Replies
    1. Are you using pagination?
      Please send me screen shots, So I can help.

      Delete
    2. No i am not using pagination. How to attach files in your blog?

      Delete
    3. This comment has been removed by the author.

      Delete
    4. Mail me at vikramblogs@gmail.com

      Delete
  22. sent the file. please check. thanks a lot.

    ReplyDelete
  23. Hi,The most commonly delivered using AJAX (Asynchornous JavaScript and XML) where the JavaScript will take a user action in Web Design Cochin and send that data to the server for processing via XML, then receive a response from the server and use JavaScript again to update the user interface (web page). Thanks...

    ReplyDelete
  24. Hi Vikram,

    thank you very much , it is really the best example in the internet, it very esay,
    you are the best.

    good luck :)

    ReplyDelete
  25. Hi Vikram,
    Do the web application with birt work in java 1.5 version?
    We have OC4J server with java 1.5 and while deploying the war file of the birt web application, error is thrown as "Operation failed with error: Error parsing annotation for class BirtIntegration.Controller.BirtReportController ". But is works fine at my localhost with java 1.6 version.
    Error is as:
    [Dec 6, 2013 10:35:20 AM] Application Deployer for BirtIntegration STARTS.
    [Dec 6, 2013 10:35:20 AM] Copy the archive to /oracle/product/web/j2ee/SahajApps/applications/BirtIntegration.ear
    [Dec 6, 2013 10:35:20 AM] Initialize /oracle/product/web/j2ee/SahajApps/applications/BirtIntegration.ear begins...
    [Dec 6, 2013 10:35:20 AM] Unpacking BirtIntegration.ear
    [Dec 6, 2013 10:35:20 AM] Done unpacking BirtIntegration.ear
    [Dec 6, 2013 10:35:20 AM] Unpacking BirtIntegration.war
    [Dec 6, 2013 10:35:22 AM] Done unpacking BirtIntegration.war
    [Dec 6, 2013 10:35:22 AM] Initialize /oracle/product/web/j2ee/SahajApps/applications/BirtIntegration.ear ends...
    [Dec 6, 2013 10:35:22 AM] Starting application : BirtIntegration
    [Dec 6, 2013 10:35:22 AM] Initializing ClassLoader(s)
    [Dec 6, 2013 10:35:22 AM] Initializing EJB container
    [Dec 6, 2013 10:35:22 AM] Loading connector(s)
    [Dec 6, 2013 10:35:22 AM] Starting up resource adapters
    [Dec 6, 2013 10:35:22 AM] Initializing EJB sessions
    [Dec 6, 2013 10:35:22 AM] Committing ClassLoader(s)
    [Dec 6, 2013 10:35:22 AM] Initialize BirtIntegration begins...
    [Dec 6, 2013 10:35:22 AM] Initialize BirtIntegration ends...
    [Dec 6, 2013 10:35:22 AM] Started application : BirtIntegration
    [Dec 6, 2013 10:35:22 AM] Binding web application(s) to site default-web-site begins...
    [Dec 6, 2013 10:35:22 AM] Binding BirtIntegration web-module for application BirtIntegration to site default-web-site under context root BirtIntegration
    [Dec 6, 2013 10:35:22 AM] Operation failed with error: Error parsing annotation for class BirtIntegration.Controller.BirtReportController

    ReplyDelete
  26. HI Vikram

    This is Great Example and thanks for sharing this.

    normally I run reports using folwong format:

    http://localhost:8080/birt-viewer/run?__report=Stock.rptdesign&ReportFormat=htm

    can't we use same run__? commands.

    Thanks
    Bathiya

    ReplyDelete
  27. Dear Vikram,
    Thanks for sharing the project.Can u explain how can i pass parameter through my java code.As u have made a static project by given a static xml.I want to pass a parameter and for that particular report should be generated.
    I tried this by using birt tool but i want to do this my web application as u did.
    Please Suggest me if u know.....

    ReplyDelete
  28. Dear Vikram,

    Thank you for the detailed explanation of using XML as a datasource and integrating this with an Web app. Could you explain how do we change this for data from POJO classes.
    For e.g., the rptdesign indicates that this has a address, list of details (this will be a table), logo (image). All these are in different POJO classes.
    Appreciate your guidance on this.
    Regards,
    Manu

    ReplyDelete
  29. Hi,
    I'm trying to run the project without pagination support, but it doesn't work. I access to http://localhost:8080/BirtIntegration page from the browser but I obtain the next message: "The requested resource () is not available".
    is there some problem in your web.xml?

    Thanks in advance!

    ReplyDelete
  30. can u provide a demo explaining how to design reports in Spring MVC with using BIRT designer?

    ReplyDelete
  31. can u provide a demo explaining how to design reports in Spring MVC without* using BIRT designer?

    ReplyDelete
  32. Dear Vikram,
    Thanx for the post and code very impressive post and detailed explanation .

    I have a doubt regarding " ' temp.rptdocument ' " file generation . I dont know wither I am in right approach.. could you plz clear it.

    temp.rptdocument file is regenerated each time for each request. if parallel many request comes.... and they will be processing parallely.. so if 1st request try to read the file after writing and at same time 2nd request try regenerate temp.rptdocument or reginerated before reading it by 1st request....... there is chance of wrong responce....

    can you please enplane me wither
    I am right or wrong.

    Thank you.

    ReplyDelete
  33. Sorry Guys I did not get chance to further improve this example. Please consider this as an reference example which you can further improve (Improve as per your need). Use documentation provided by eclipse to suite your needs.

    Thanks

    ReplyDelete
  34. Hiee..!!!
    Vikram I really appreciate your effort I have successfully installed your example in my app if you can post or mail a simple example how to get report according to passed parameters i will be very thankful to you...

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hi Chetan it's typically form parameters you need to send in ajax request which will act as report parameter. It's difficult for me spend time now. But I am sure if you spend some time on class ReportRenderer you will understand how request parameters are converted to report parameter. Check below method in ReportRenderer :
      processReportDesignDocAndRenderReport(...)
      discoverAndSetParameters(...) (this method where you should go)

      I would suggest you should go though part1 of this post and simultaneously debug code.

      Thanks

      Delete
    3. Hi Vikram can u post Query to be written for paramiterized report in data set
      i have written "Select * from User where deptId = ?" but its show error.
      plz reply or you can mail me @aditya26anand@gmail.com

      Delete
  35. my mailid is chetanmoulekhi@gmail.com

    ReplyDelete
  36. Hi Vikram,

    its very good example. but I can not create a link to another report.
    I created a blank report, and became the author hyperlink column, and I tried both options and URI drill-through direct to the new report, but both messages generate open a new page with the error message.

    ReplyDelete
  37. Hi Virkram,

    I plan to integrate BIRT with my existing web application. Do you think that it would be possible to integrate viewer like your in example with the window using EXT JS 4 ? I mean I'd like to create webapp using Ext, where one functionality is reporting tool with a viewer like yours.

    Regards,
    Michael

    ReplyDelete
    Replies
    1. Yes, It is possible to integrate.I have used jQuery framework for javascript. You need to make changes in "report.js" to support EXT JS.

      Delete
  38. Hi Vikram,
    Thank you very much for the wonderful example.. I have downloaded your example and try to run.. find the following error
    Can you please advice..

    Jun 09, 2014 3:20:06 PM org.eclipse.birt.report.engine.api.impl.ReportEngineHelper openReportDesign
    SEVERE: D:\eclipseBIRT\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BirtIntegration\Reports\null not found!

    ReplyDelete
  39. Amazing Vikram... This is of great help!
    Awaiting few most posts like this... :)

    ReplyDelete
  40. Great Example..Can you please explain how to integrate this project with Struts?

    ReplyDelete
  41. Hi Vikram,
    I am using birt 4.3.2,I would like to ask you,
    - Can we externalize birt database so that when we change DB environment we just need to do change in only one place as nw I need to change each and every rptdesign file.
    - Can we Download a report in xlsx format(if yes,can u provide me code for that with images and graph)
    - How Can we pass multiple values to a single parameter in birt report(please provide me code for that)

    ReplyDelete
  42. great work ..! very helpful..!

    but i have a question here that,

    if i have installed birt plugin in eclipse (indigo) or any other on ubuntu o.s.
    so i am unable to find birt engine runtime\lib there, so i need to download only birt runtime from net again to find and add jars to WEB-INF/lib

    that means i done double download

    is there any other alternate for this ... or i am doing something wrong

    i followed these steps
    1)instlled plugins for birt 3.7
    2)came on this blogpost and started following procedure
    3)downloaded source code
    4)...stuck for library files.
    ...
    ...
    5) again downloaded birt runtime only
    6) located jar's
    7)added to WEB-INF\lib

    8)HAVING FUN....

    IS IT A RIGHT WAY?

    ReplyDelete
  43. Hai Vikram,


    Hi, I need to generate report through jsp page. For example, there is a country dropdown in jsp, select any country & submit, generate the BIRT report with data for the selected country in same or another jsp

    please help me..this is urgent task for me.

    ReplyDelete
  44. Is this possible if web app doesn't use jsp pages?

    ReplyDelete
    Replies
    1. yes possible to use jsp page or static html page as a front end.
      but ultimately request should be sent to birt engine so it must be handles by HTTPServlet or other servlet or a jsp page and forward to a birt singleton handler class

      Delete
  45. Hi Vikram!

    Thanks for sharing your knowledge.

    I'm trying to apply the your JSP example. What I get on the web-page, when clicking on both reports in the left div is the following messafe in the central div : "Sorry but there was an error getting details ! 404 Servlet loadReport is not available". As far as I understand, tomcat web-server cannot locate required servlet "loadReport", which is described in web.xml file. How we sort this problem out? Where this servlet actually located?

    ReplyDelete
  46. Hi Vikram!
    Thanks for sharing your knowledge.
    Have an idea how integrate the internationnalization : label , title ...
    I do like this
    -declared files xxx.properties and xxx_fr.properties copied in the same repositories of my *.rptdesign
    - In rptdesign add

    xxx
    xxx_fr


    exemple of use key in my template


    method run report
    iRunTask.setLocale(locale); //locale provided from servlet

    but when running the report it dasn't work
    Anu idea how to resolve problem

    ReplyDelete
  47. - In rptdesign add

    <simple-property-list name="includeResource">
    InstanceByState</value>
    InstanceByState_fr</value>
    </simple-property-list>


    example of use key in my template
    <text-property name="title" key="title">Instance by states</text-property>

    ReplyDelete
  48. Hi Vikram

    can you please help me how to get dynamic data from database using BIRT please.....

    ReplyDelete
  49. Hi Vikram

    can you please help me how to get dynamic data from database using BIRT please.....

    in this sample example static data is displaying how to get dynamic data please help me out as soon as possible its very very important ......


    mail me @ ngr.shakti@gmail.com

    ReplyDelete
  50. Hi Vikram

    can you please help me how to get dynamic data from database using BIRT please.....

    in this sample example static data is displaying how to get dynamic data please help me out as soon as possible its very very important ......


    mail me @ ngr.shakti@gmail.com

    ReplyDelete
  51. Great example with good illustration. Any has idea on how this can work with the grails framework? Thank you.

    ReplyDelete
  52. Any one has idea to integrate BIRT with seam framework? Thank you.

    ReplyDelete
  53. Any one has idea to integrate BIRT with seam framework? Thank you.

    ReplyDelete


  54. Thanks for sharing, I will bookmark and be back again

    Google App Integration Chennai

    ReplyDelete
  55. This is a really great example to start with Birt. Thanks for sharing.
    I spent some time struggling to find the correct URL to hit the report though.
    Found it after debugging ReportRenderer class.
    The URL for one of the reports is: http://localhost:8080/BirtIntegration/loadReport?ReportName=books_report.rptdesign

    In case you are interested, I am using this platform to test:
    Eclipse IDE for Java and Report Developers
    Version: Mars Release (4.5.0)
    JDK 1.7.0_79
    Tomcat 7.0.69

    ReplyDelete
  56. This comment has been removed by the author.

    ReplyDelete
  57. To access Reports.jsp use below url
    http://localhost:8080/BirtIntegration/jsp/Reports.jsp

    Very nice post :)

    ReplyDelete
  58. this article is what I'm looking for ,thanks for sharing this information but could you please share the web project example cause the link is broken

    ReplyDelete
  59. hi vikram ,
    thanks for sharing such a good article, can you please share the web project example, the link is not working

    ReplyDelete
  60. Thanks for sharing . Could you please share the web project link ?

    ReplyDelete