• XMLItergration.java


    /*===========================================================================+
     |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
     |                         All rights reserved.                              |
     +===========================================================================+
     |  HISTORY                                                                  |
     +===========================================================================*/
    package oareport.oracle.apps.ak.webui;
    
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.server.OADBTransactionImpl;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletResponse;
    import oracle.apps.fnd.framework.webui.beans.table.OAAdvancedTableBean;
    import oracle.apps.xdo.oa.schema.server.TemplateHelper;
    import oracle.apps.fnd.framework.OAException;
     import oracle.cabo.ui.data.DataObject;
     import oracle.apps.xdo.XDOException;
    
    import oracle.jbo.XMLInterface;
    
    import oracle.xml.parser.v2.XMLNode;
    import java.lang.System;
    import oracle.apps.xdo.oa.schema.server.TemplateInputStream;
    import oracle.apps.xdo.common.log.Logger;
    
    /**
     * Controller for ...
     */
    public class XMLIntegrationCO extends OAControllerImpl
    {
      public static final String RCS_ID="$Header$";
      public static final boolean RCS_ID_RECORDED =
            VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    
      /**
       * Layout and page setup logic for a region.
       * @param pageContext the current OA page context
       * @param webBean the web bean corresponding to the region
       */
      public void processRequest(OAPageContext pageContext, OAWebBean webBean)
      {
        super.processRequest(pageContext, webBean);
        OAApplicationModule am= pageContext.getApplicationModule(webBean);
       // am.invokeMethod("initEmpVO");
       // am.invokeMethod("getEmpDataXML");
    
      }
    
      /**
       * Procedure to handle form submissions for form elements in
       * a region.
       * @param pageContext the current OA page context
       * @param webBean the web bean corresponding to the region
       */
      public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
      {     
           super.processFormRequest(pageContext, webBean);
        OAApplicationModule am= (OAApplicationModule)pageContext.getApplicationModule(webBean);
        //String event = pageContext.getParameter("event");
                      DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
    
                       HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
        
        
        if(pageContext.getParameter("PrintPdf") != null)
          {
    
                      try {
    
                                               ServletOutputStream os = response.getOutputStream();
    
                                                // Set the Output Report File Name and Content Type
    
                                                String contentDisposition = "attachment;filename=PrintPage.pdf";
    
                                                response.setHeader("Content-Disposition",contentDisposition);
    
                                                response.setContentType("application/pdf");
    
                                                // Get the Data XML File as the XMLNode
    
                                                XMLNode xmlNode = (XMLNode) am.invokeMethod("getEmpDataXML");
                           
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                                   xmlNode.print(outputStream);
                               //    System.out.println(outputStream.toString());  
                                 ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    
                                 ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
    
                                 //Generate the PDF Report.
    
                                 //Process Template
    
                                 TemplateHelper.processTemplate(
    
                                 ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
    
                                 "PER",//APPLICATION SHORT NAME
    
                                 "EmpDataDT", //TEMPLATE_SHORT_CODE
    
                                 ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
    
                                 ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
    
                                 inputStream,
    
                                 TemplateHelper.OUTPUT_TYPE_PDF,
    
                                 null,
    
                                 pdfFile);
    
                                   //TemplateHelper.
    
                                 // Write the PDF Report to the HttpServletResponse object and flush.
    
                                 byte[] b = pdfFile.toByteArray();
    
                                 response.setContentLength(b.length);
    
                                 os.write(b, 0, b.length);
    
                                 os.flush();
    
                                 os.close();
    
                         pdfFile.flush();
    
                         pdfFile.close();
    
                                 }
    
                                 catch(Exception e)
    
                                 {
    
                                 response.setContentType("text/html");
                                //System.out.println(e.getMessage());
                                 throw new OAException(e.getMessage(), OAException.ERROR);
    
                                 }
    
                                 pageContext.setDocumentRendered(true);
    
                                 } 
    
         
         
                      
                      if(pageContext.getParameter("PrintExcel") != null)
                        {
    
                                    try {
    
                                                             ServletOutputStream os = response.getOutputStream();
    
                                                              // Set the Output Report File Name and Content Type
    
                                                              String contentDisposition = "attachment;filename=ExcelReport.xls";
    
                                                              response.setHeader("Content-Disposition",contentDisposition);
    
                                                              response.setContentType("application/MSEXCEL");
    
                                                              // Get the Data XML File as the XMLNode
    
                                                              XMLNode xmlNode = (XMLNode) am.invokeMethod("getEmpDataXML");
                                         
                      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                                                 xmlNode.print(outputStream);
                                             //    System.out.println(outputStream.toString());  
                                               ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    
                                               ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
    
                                               //Generate the PDF Report.
    
                                               //Process Template
    
                                               TemplateHelper.processTemplate(
    
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
    
                                               "PER",//APPLICATION SHORT NAME
    
                                               "EmpDataDT", //TEMPLATE_SHORT_CODE
    
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
    
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
    
                                               inputStream,
    
                                               TemplateHelper.OUTPUT_TYPE_EXCEL,
    
                                               null,
    
                                               pdfFile);
    
                                                 //TemplateHelper.
    
                                               // Write the PDF Report to the HttpServletResponse object and flush.
    
                                               byte[] b = pdfFile.toByteArray();
    
                                               response.setContentLength(b.length);
    
                                               os.write(b, 0, b.length);
    
                                               os.flush();
    
                                               os.close();
    
                                       pdfFile.flush();
    
                                       pdfFile.close();
    
                                               }
    
                                               catch(Exception e)
    
                                               {
    
                                               response.setContentType("text/html");
                                              //System.out.println(e.getMessage());
                                               throw new OAException(e.getMessage(), OAException.ERROR);
    
                                               }
    
                                               pageContext.setDocumentRendered(true);
    
                                               }
         
                      if(pageContext.getParameter("PrintWord") != null)
                        {
    
                                    try {
    
                                                             ServletOutputStream os = response.getOutputStream();
    
                                                              // Set the Output Report File Name and Content Type
    
                                                              String contentDisposition = "attachment;filename=PrintPage.doc";
    
                                                              response.setHeader("Content-Disposition",contentDisposition);
    
                                                              response.setContentType("application/MSWORD");
    
                                                              // Get the Data XML File as the XMLNode
    
                                                              XMLNode xmlNode = (XMLNode) am.invokeMethod("getEmpDataXML");
                                         
                      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                                                 xmlNode.print(outputStream);
                                             //    System.out.println(outputStream.toString());  
                                               ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    
                                               ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
    
                                               //Generate the PDF Report.
    
                                               //Process Template
    
                                               TemplateHelper.processTemplate(
    
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
    
                                               "PER",//APPLICATION SHORT NAME
    
                                               "EmpDataDT", //TEMPLATE_SHORT_CODE
    
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
    
                                               ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
    
                                               inputStream,
    
                                               TemplateHelper.OUTPUT_TYPE_RTF,
    
                                               null,
    
                                               pdfFile);
    
                                                 //TemplateHelper.
    
                                               // Write the PDF Report to the HttpServletResponse object and flush.
    
                                               byte[] b = pdfFile.toByteArray();
    
                                               response.setContentLength(b.length);
    
                                               os.write(b, 0, b.length);
    
                                               os.flush();
    
                                               os.close();
    
                                       pdfFile.flush();
    
                                       pdfFile.close();
    
                                               }
    
                                               catch(Exception e)
    
                                               {
    
                                               response.setContentType("text/html");
                                              //System.out.println(e.getMessage());
                                               throw new OAException(e.getMessage(), OAException.ERROR);
    
                                               }
    
                                               pageContext.setDocumentRendered(true);
    
                                               }
         
         
         
         
         
         
         
         
         
                    }
    
                   
                    
    
            
        
        
        
            
          
          
    }


    public XMLNode getEmpDataXML()
    {
      OAViewObject vo = (OAViewObject)findViewObject("AbcVO"); 
      XMLNode xmlNode = (XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS);
      return xmlNode;
    }
  • 相关阅读:
    故障诊断 | 系统级追踪诊断方法及案例分享
    Linux 一个网卡添加多个IP
    DB2 Vs MySQL系列 | MySQL与DB2的数据类型对比
    新年寄语 | 2018 以及 Oracle 18c 一个时代的开启
    perl 全文搜索tr/td标签内容
    perl 监控activemq队列
    年终总结 | 从Oracle到MySQL大家最关注的竟然是...
    辞旧迎新:2018年的分区你们建了吗?
    mysql 执行长sql
    Ubuntu搭建NTP服务器
  • 原文地址:https://www.cnblogs.com/huanghongbo/p/4828372.html
Copyright © 2020-2023  润新知