This discussion is archived
3 Replies Latest reply: May 8, 2012 5:35 AM by 862073 RSS

jasper report integration in Oracle BPM

862073 Newbie
Currently Being Moderated
Hello friends

We'r working on an application using Oracle BPM 11g (11.1.1.5.0)

What we are looking for is to have the ability to generate reports using iReport (jasper).

Using help from the previous thread below ,we have been able to call a report without any input parameters and by calling the servlet directly.

Re: generating jasper reports in Oracle BPM

What we're trying to do here is to have some input parameters for our report.
I'm trying to do this using a java class, but haven't found any sample to show me the way and samples I've found didn't work in Oracle BPM

Can anyone help me with this?
Thank you
  • 1. Re: jasper report integration in Oracle BPM
    Sudipto Desmukh Expert
    Currently Being Moderated
    If you need to generated the Jasper report from the ADF UI taskform which is generated from BPM you can follow these -
    http://sameh-nassar.blogspot.in/2009/10/using-jasper-reports-with-jdeveloper.html
    http://www.gebs.ro/blog/oracle/jasper-reports-in-adf/

    Also in case you face simialr issues while inegrating it you can look for the solution here
    generating jasper reports in Oracle BPM
  • 2. Re: jasper report integration in Oracle BPM
    862073 Newbie
    Currently Being Moderated
    Hello Sudipto

    Thank you for your quick reply but that's my own thread as i mentioned in the question section.
    I forgot to mention it at first, I guess your reply came when I was editing my question.
    sorry about that.
  • 3. Re: jasper report integration in Oracle BPM
    862073 Newbie
    Currently Being Moderated
    Hi
    I have finally solved my problem.
    The problem was that I could not send the input parameter to the servlet.
    Here is my code:

    in my java class:
    public String actionRunReport() throws Exception {
            // Add event code here...
    
            String emp = null;
            if (getEmployeeID().getValue() != null) {
                emp = getEmployeeID().getValue().toString();
            } else {
                emp = "1";
            }
    
    
            FacesContext ctx = FacesContext.getCurrentInstance();
            HttpServletRequest request =
                (HttpServletRequest)ctx.getExternalContext().getRequest();
            HttpServletResponse response =
                (HttpServletResponse)ctx.getExternalContext().getResponse();
    
            request.setAttribute("empId", emp);
            
            request.getRequestDispatcher(response.encodeURL("/printrrportservlet")).forward(request,
                                                                                            response);
            response.flushBuffer();
            ctx.responseComplete();
            return null;
        }
    in my servlet:
    public void doPost(HttpServletRequest request,
                           HttpServletResponse response) throws ServletException,
                                                                IOException {
    
            response.setContentType(CONTENT_TYPE);
            //OutputStream ouputStream = null;
            try {
                Connection conn = Connect.createConnection();
                String reportSource = "C:\\reports\\templates\\guarantees.jrxml";
    
                InputStream input = new FileInputStream(new File(reportSource));
    
                JasperDesign design = JRXmlLoader.load(input);
                JasperReport report = JasperCompileManager.compileReport(design);
    
                Map<String, Object> params = new HashMap<String, Object>();
    
                params.put("reportTitle", "Guarantees");
                params.put("author", "Milad");
                params.put("startDate", (new java.util.Date()).toString());
    
                params.put("empId", request.getAttribute("empId"));
    
                JasperPrint jasperPrint =
                    JasperFillManager.fillReport(report, params, conn);
    
                OutputStream ouputStream = response.getOutputStream();
                JRExporter exporter = null;
    
    
                response.setContentType("application/pdf");
                
    
                exporter = new JRPdfExporter();
    
                exporter.setParameter(JRExporterParameter.JASPER_PRINT,
                                      jasperPrint);
                exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,
                                      ouputStream);
                exporter.exportReport();
    
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    In jspx page::
    <af:commandButton text="Run report" id="cb1"
       action="#{printBean.actionRunReport}"/>
    in web.xml:
    <servlet-mapping>
        <servlet-name>PrintrRportServlet</servlet-name>
        <url-pattern>/printrrportservlet</url-pattern>
    </servlet-mapping>

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points