Anil's Blog is Best Viewed on GOOGLE CHROME

Sunday, January 11, 2015

Integrate XML Publisher Report with OAF

In this example we are going to integrate a simple XML publisher report with OAF. The business scenario is something like that we have a OAF page and on click of "Print" button we want to call a XML publisher report.

1. Create a OAF page with table region and print button to call a XML publisher report.

2. Designed XML report template. here I have not mentioned steps to register the XML report in Oracle apps.

Controller Code
Here we are handling the print button action and calling the XML report.
    public void processFormRequest(OAPageContext pageContext, 
                                   OAWebBean webBean) {
        super.processFormRequest(pageContext, webBean);
        if (pageContext.getParameter("Print") != null) {

            System.out.println("Print Button clicked");

            printReport(pageContext, webBean, "pdf");


    public void printReport(OAPageContext pageContext, OAWebBean webBean, 
                            String outputType) {

        OAApplicationModule lo_am = pageContext.getApplicationModule(webBean);
        String ls_extensionType = "pdf"; //Setting the output extension type
        byte l_outputType = 0;
        l_outputType = TemplateHelper.OUTPUT_TYPE_PDF;

        DataObject lo_sessionDictionary = 
        HttpServletResponse lo_response = 
        try {
            ServletOutputStream lo_outputStream = 

            // setting the report name & output type
            String lo_contentDisposition = 
                "attachment;filename=OrderDetails." + ls_extensionType;

            System.out.println("Calling XML generation method");

            XMLNode xmlNode = 
            // Calling getOrderReportDetailsXML method to get the XML for the VO query

            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

            System.out.println("After calling XML generation method" + 
            //Above sop will return the XML output which will help you in designing the template.
            ByteArrayInputStream lo_inputStream = 
                new ByteArrayInputStream(outputStream.toByteArray());
            ByteArrayOutputStream lo_outputFile = new ByteArrayOutputStream();
            // Pass the Template code and Application short name
            try {
                                               "PA", "XX_ORDER_DT", 
                                               lo_inputStream, l_outputType, 
                                               null, lo_outputFile);

            } catch (XDOException xe) {
                throw new OAException("Exception:" + xe.getMessage());


            byte[] l_bytes = lo_outputFile.toByteArray();

            lo_outputStream.write(l_bytes, 0, l_bytes.length);
        } catch (Exception e) {
            throw new OAException(e.getMessage(), OAException.ERROR);


Application Module Code

 This method will return the XML output of the VO query attached to the page.

   public XMLNode getOrderReportDetailsXML() {
        //XMLNode lo_xmlNode;
       System.out.println("Inside the AM Method");
        OrderReportDetailsVOImpl vo = getOrderReportDetailsVO1();
          XMLNode  lo_xmlNode = (XMLNode)vo.writeXML(-1, 0L);

//OL Stands for XMLInterface.XML_OPT_ALL_ROWS which means to includes all rows in the view object's row set in the XML.

        return lo_xmlNode;

Report Output


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.