原文地址: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 = "CUX_CHANGEMEMO_TEMPLATE_ENG"; TemplateHelper.processTemplate(oaTrans.getAppsContext(), "CUX", 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; 红无备注:此处建议释放临时templob,否则可能带来某些异常,如Temporary LOB导致临时表空间暴满
写法如下
vn_xml_clob              clob;
vs_xml_str               clob;  --临时变量
vs_xml_str:='<PRODUCTLIST></PRODUCTLIST>' //这样的赋值应该是vs_xml_str直接当作varchar2类型来用了,oracle自己转换的,因为如果后面那个串太长了,这样符赋是会报错的。
dbms_lob.createtemporary(vn_xml_clob, TRUE); --初始化clob对象表空间
dbms_lob.append(vn_xml_clob, vs_xml_str); ---把字符串拼接给clob对象
os_xml:=vn_xml_clob;
dbms_lob.freetemporary(vn_xml_clob); --用完了释放空间
 
原因参考另外一篇博客

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 cux_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 = "CUX_CONTRACT_PAYMENT_REQUEST";
TemplateHelper.processTemplate(oaTrans.getAppsContext(), "CUX", 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);
}
vn_xml_clob              clob;
vs_xml_str               clob;  --临时变量
vs_xml_str:='<PRODUCTLIST></PRODUCTLIST>' //这样的赋值应该是vs_xml_str直接当作varchar2类型来用了,oracle自己转换的,因为如果后面那个串太长了,这样符赋是会报错的。
dbms_lob.createtemporary(vn_xml_clob, TRUE); --初始化clob对象表空间
dbms_lob.append(vn_xml_clob, vs_xml_str); ---把字符串拼接给clob对象
os_xml:=vn_xml_clob;
dbms_lob.freetemporary(vn_xml_clob); --用完了释放空间

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

  1. OAF_开发系列16_实现OAF与XML Publisher整合

    http://wenku.baidu.com/link?url=y2SFKHP5qqn4bl_iNeqLGjXsTvhyFuhkMraIbWZdTXbzcv0vTefrZFFBDWie0cAAKuTw ...

  2. 使用XML Publisher导出PDF报表

    生成XML数据源有两种方式. 一种是使用存储过程,返回一个clob作为xml数据源. 另一种是直接使用VO中的数据生成xml数据源. 方法一参考: Oracle XML Publisher技巧集锦 O ...

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

    OAF doesn't readily expose the Controller Servlet's HttpRequest and HttpResponse objects so you need ...

  4. How to Delete XML Publisher Data Definition Template

    DECLARE  -- Change the following two parameters  VAR_TEMPLATECODE  VARCHAR2(100) := 'CUX_CHANGE_RPT1 ...

  5. BIP_开发案例07_将原有Report Builer报表全部转为XML Publisher形式(案例)

    2014-05-31 Created By BaoXinjian

  6. 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 gen ...

  7. xml publisher根据条件显示或隐藏列

     xml publisher根据条件显示或隐藏列 <?if@column:condition? > -- <?end if?> 样例: 依据PROJECT_FLAG标签显示 ...

  8. XML Publisher Report Issues, Recommendations and Errors

    In this Document   Purpose   Questions and Answers   References APPLIES TO: Oracle Process Manufactu ...

  9. XML Publisher Using API’s(转)

    原文地址:XML Publisher Using API’s Applications Layer APIsThe applications layer of XML Publisher allows ...

随机推荐

  1. STL--迭代器(iterator)

    指针与数组 指针与其它数据结构呢?比如说链表? 存储空间是非连续的.不能通过对指向这种数据结构的指针做累加来遍历. 能不能提供一个行为类似指针的类,来对非数组的数据结构进行遍历呢?这样我们就能够以同样 ...

  2. 【读书笔记】iOS-类别

    一,类别是一种为现有的类添加新方法的方式. 二,类别的局限性. 1,无法向类中添加新的实例变量.类别没有位置容纳实例变量. 2,名称冲突,即类别中的方法与现有的方法重名.当发生名称冲突时,类别具有更高 ...

  3. IOS GCD 浅析

     一.简单介绍 1.队列的类型:      1.1主队列:main queue 主线程队列,更新UI的操作.是一个串行的队列,串行队列每次只处理一个任务.      1.2系统创建的并发队列:glob ...

  4. 深入理解Android的startservice和bindservice

    一.首先,让我们确认下什么是service?         service就是android系统中的服务,它有这么几个特点:它无法与用户直接进行交互.它必须由用户或者其他程序显式的启动.它的优先级比 ...

  5. iOS 清理缓存功能的实现第二种方法

    /** * 清理缓存第二种方法 * * @param sender <#sender description#> */ - (void)clearCache:(id)sender { // ...

  6. Swift字符与字符串

    学习来自<极客学院:Swift中的字符串和集合> 工具:Xcode6.4 直接上基础的示例代码,多敲多体会就会有收获:百看不如一敲,一敲就会 import Foundation /**** ...

  7. Android开发艺术探索学习笔记(三)

    第三章  View的事件体系 3.1 View基础知识 3.1.1 什么是view View 是Android中所有控件的基类,是一种界面层的控件的一种抽象,它代表了一个控件. 3.1.2 View的 ...

  8. Effective Java 05 Avoid creating unnecessary objects

    String s = new String("stringette"); // Don't do this. This will create an object each tim ...

  9. linux 同步IO: sync msync、fsync、fdatasync与 fflush

    最近阅读leveldb源码,作为一个保证可靠性的kv数据库其数据与磁盘的交互可谓是极其关键,其中涉及到了不少内存和磁盘同步的操作和策略.为了加深理解,从网上整理了linux池畔同步IO相关的函数,这里 ...

  10. SpringMVC4 + Spring + MyBatis3 基于注解的最简配置

    本文使用最新版本(4.1.5)的springmvc+spring+mybatis,采用最间的配置方式来进行搭建. 1. web.xml 我们知道springmvc是基于Servlet: Dispatc ...