OAF与XML Publisher集成(转)

原文地址:OAF与XML Publisher集成

有两种方式,一种是用VO与XML Publisher集成,另一种是用PL/SQL与XML Publisher集成

用VO与XML Publisher集成

用VO生成数据.AM里调用

在application module新增方法:

import oracle.jbo.XMLInterface;
import oracle.xml.parser.v2.XMLNode;
public XMLNode getReportXMLNode(String keyId)
{
  ChgDisPrintTmpVOImpl vo = getChgDisPrintTmpVO1();
  vo.executeQuery();
  XMLNode xmlNode = ((XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS));
  return xmlNode;
}

用CO调用方法

增加一个funciton

public void PrintPDF(OAPageContext pageContext, OAWebBean webBean, XMLNode xmlNode, String keyId)
  {
    HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
    String changeOrderType = pageContext.getParameter("ChangeOrderType");
    // Set the Output Report File Name and Content Type
    String contentDisposition = "attachment;filename=Distribution" + keyId + ".pdf";
    response.setHeader("Content-Disposition", contentDisposition);
    response.setContentType("application/pdf");
    try
    {
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      xmlNode.print(outputStream);
      //xmlNode.print(System.out);
      ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
      OADBTransactionImpl oaTrans =
        (OADBTransactionImpl) pageContext.getApplicationModule(webBean).getOADBTransaction();
      String templateName = "XVK_CHANGEMEMO_TEMPLATE_ENG";

      TemplateHelper.processTemplate(oaTrans.getAppsContext(), "XVK", templateName, "zh", "CN", inputStream,
                                     TemplateHelper.OUTPUT_TYPE_PDF, null, response.getOutputStream());

      response.getOutputStream().flush();
      response.getOutputStream().close();
    }
    catch (Exception e)
    {
      response.setContentType("text/html");
      throw new OAException(e.getMessage(), OAException.ERROR);
    }

    pageContext.setDocumentRendered(false);
  }

修改CO processFormRequest事件

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
  String event = pageContext.getParameter(EVENT_PARAM);

if("print".equals(event))
{
      String KeyId = pageContext.getParameter("KeyId");
      parameters = new Serializable[] { KeyId };
      XMLNode xmlNode = (XMLNode) am.invokeMethod("getReportXMLNode ", parameters);
      PrintDisPDF(pageContext, webBean, xmlNode, KeyId);
  }
}


用PL/SQL与XML Publisher集成

用PL/SQL方法实例

PROCEDURE print_payment_request(p_payment_request_id IN NUMBER,
                                x_out_xml            OUT CLOB) IS
BEGIN
    dbms_lob.createtemporary(x_out_xml,
                             TRUE);
    l_temp_str := ‘<?xml version="1.0" encoding="UTF-8"?>‘ || chr(10) || ‘<HEADERDATA>‘ || chr(10);
    dbms_lob.writeappend(lob_loc => x_out_xml,
                         amount  => length(l_temp_str),
                         buffer  => l_temp_str);
    l_temp_str := l_temp_str || ‘<MATERIALS>‘ || r_h.materials || ‘</MATERIALS>‘ || chr(10);
    l_temp_str := ‘</HEADERDATA>‘;
    dbms_lob.writeappend(lob_loc => x_out_xml,
                         amount  => length(l_temp_str),
                         buffer  => l_temp_str);
END;

AM调用方法

public CLOB getPaymentRequestXMLClob(String paymentRequestId)
{
  Number reqId = null;
  CLOB tempClob = null;
  OADBTransaction oaDbTrans = getOADBTransaction();
  OracleCallableStatement stmt = null;
  try
  {
    reqId = new Number(paymentRequestId);
    String strSQL =
      "BEGIN xvk_contract_reports_pkg.print_payment_request(p_payment_request_id=> :1,x_out_xml=>:2); END;";
    stmt = (OracleCallableStatement) oaDbTrans.createCallableStatement(strSQL, 1);
    stmt.setNUMBER(1, reqId);
    stmt.registerOutParameter(2, Types.CLOB);
    stmt.execute();
    tempClob = stmt.getCLOB(2);
    stmt.close();
  }
  catch (Exception exception1)
  {
    throw OAException.wrapperException(exception1);
  }

  return tempClob;
}

CO调用方法

public void PrintPDF(OAPageContext pageContext, OAWebBean webBean, CLOB xmlClob)
{
  HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
  // Set the Output Report File Name and Content Type
  String contentDisposition = "attachment;filename=PaymentRequest.pdf";
  response.setHeader("Content-Disposition", contentDisposition);
  response.setContentType("application/pdf");
  try
  {
    Reader inputReader = xmlClob.getCharacterStream();
    OADBTransactionImpl oaTrans =
      (OADBTransactionImpl) pageContext.getApplicationModule(webBean).getOADBTransaction();
    String templateName = "XVK_CONTRACT_PAYMENT_REQUEST";
    TemplateHelper.processTemplate(oaTrans.getAppsContext(), "XVK", templateName, "zh", "CN", inputReader,
                                   TemplateHelper.OUTPUT_TYPE_PDF, null, response.getOutputStream());

    response.getOutputStream().flush();
    response.getOutputStream().close();
  }
  catch (Exception e)
  {
    response.setContentType("text/html");
    throw new OAException(e.getMessage(), OAException.ERROR);
  }

  pageContext.setDocumentRendered(false);
}

修改CO事件 processFormRequest

String event = pageContext.getParameter(EVENT_PARAM);

if("print".equals(event)) {
    String paymentRequestId = pageContext.getParameter("paymentRequestId");
    Serializable[] param = {paymentRequestId};
    CLOB tempClob = (CLOB) am.invokeMethod("getPaymentRequestXMLClob",param);
    PrintPDF(pageContext, webBean ,tempClob);
  }
时间: 2025-01-16 12:44:12

OAF与XML Publisher集成(转)的相关文章

使用XML Publisher导出PDF报表

生成XML数据源有两种方式. 一种是使用存储过程,返回一个clob作为xml数据源. 另一种是直接使用VO中的数据生成xml数据源. 方法一参考: Oracle XML Publisher技巧集锦 OAF与XML Pulisher集成 方式二: CO if ( "PrintDis".equals(l_enent)) { String DistributionId = pageContext.getParameter("DistributionId"); parame

OAF 中下载使用XML Publisher下载PDF附件

OAF doesn't readily expose the Controller Servlet's HttpRequest and HttpResponse objects so you need to extract it from the OAPageContext object via: HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletRes

How to Delete XML Publisher Data Definition Template

DECLARE  -- Change the following two parameters  VAR_TEMPLATECODE  VARCHAR2(100) := 'CUX_CHANGE_RPT1'; -- Template Code  BOO_DELETEDATADEF BOOLEAN := TRUE; -- delete the associated Data Def.BEGIN  FOR RS IN (SELECT T1.APPLICATION_SHORT_NAME TEMPLATE_

BIP_Case_将原有Report Builer报表全部转为XML Publisher形式

一.案例分析 Oracle Report Builder  因落伍的技术和糟糕的交互性,特别是无法随心所欲的进行排版,逐渐被淘汰,而BI(XML) Publisher  也是其中的一种替代技术, 此文介绍了如何将Report Builder建立的RDF文件转换成最新的XML Publisher所使用的xml data definition 和 rtf template definition,从而实现数据源和输出模板分离,从而将原有难易维护的report builder 替代为易维护的XML Pu

在页面和请求中分别使用XML Publisher生成PDF报表且自动上传至附件服务器

两个技术要点: 1.使用TemplateHelper.processTemplate方法生成目标PDF的InputStream流,再使用ftp中上传流的方法将其上传至附件服务器. 2.在请求中调用AM. 其中最重要的方法便是在请求中调用AM. SourcingPrintingAMImpl am = (SourcingPrintingAMImpl)getSourcingAppModule(cpContext); OADBTransaction trans = am.getOADBTransacti

Spring 4与Struts 2项目基于XML的集成实战

Spring 4与Struts 2项目基于XML的集成实战 作者:chszs,版权所有,未经同意,不得转载.博主主页:http://blog.csdn.net/chszs 为什么要写这篇Hello World级别的文章.大约十年前,我开始使用Spring 2和Struts 1开发Web应用,构建工具使用的是Ant.早些年,把多个框架集成在一起并不容易,各框架间的兼容性也没有现在这么好.不管怎么样,这些基础的框架伴随我们多年.如今十年过去了,沧海桑田,Spring框架和Struts框架都经过了无数

How to Determine the Version of Oracle XML Publisher for Oracle E-Business Suite 11i and Release 12 (Doc ID 362496.1)

Modified: 29-Mar-2014 Type: HOWTO In this DocumentGoal   Solution   1. Based upon an output file generated by XML Publisher   2. Based upon the applied patches   2.1. Oracle E-Business Suite 11i   2.2. Oracle E-Business Suite Release 12.0 and 12.1  

XML Publisher Report Issues, Recommendations and Errors

In this Document   Purpose   Questions and Answers   References APPLIES TO: Oracle Process Manufacturing Financials - Version 11.5.9 to 12.1.3 [Release 11.5 to 12.1] Information in this document applies to any platform. All reports that uses XML publ

BIP_将原有Report Builer报表全部转为XML Publisher形式(案例)

一.案例分析 Oracle Report Builder  因落伍的技术和糟糕的交互性,特别是无法随心所欲的进行排版,逐渐被淘汰,而BI(XML) Publisher  也是其中的一种替代技术, 此文介绍了如何将Report Builder建立的RDF文件转换成最新的XML Publisher所使用的xml data definition 和 rtf template definition,从而实现数据源和输出模板分离,从而将原有难易维护的report builder 替代为易维护的XML Pu