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 = "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集成(转)的更多相关文章
- OAF_开发系列16_实现OAF与XML Publisher整合
http://wenku.baidu.com/link?url=y2SFKHP5qqn4bl_iNeqLGjXsTvhyFuhkMraIbWZdTXbzcv0vTefrZFFBDWie0cAAKuTw ...
- 使用XML Publisher导出PDF报表
生成XML数据源有两种方式. 一种是使用存储过程,返回一个clob作为xml数据源. 另一种是直接使用VO中的数据生成xml数据源. 方法一参考: Oracle XML Publisher技巧集锦 O ...
- OAF 中下载使用XML Publisher下载PDF附件
OAF doesn't readily expose the Controller Servlet's HttpRequest and HttpResponse objects so you need ...
- How to Delete XML Publisher Data Definition Template
DECLARE -- Change the following two parameters VAR_TEMPLATECODE VARCHAR2(100) := 'CUX_CHANGE_RPT1 ...
- BIP_开发案例07_将原有Report Builer报表全部转为XML Publisher形式(案例)
2014-05-31 Created By BaoXinjian
- 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 ...
- xml publisher根据条件显示或隐藏列
xml publisher根据条件显示或隐藏列 <?if@column:condition? > -- <?end if?> 样例: 依据PROJECT_FLAG标签显示 ...
- XML Publisher Report Issues, Recommendations and Errors
In this Document Purpose Questions and Answers References APPLIES TO: Oracle Process Manufactu ...
- XML Publisher Using API’s(转)
原文地址:XML Publisher Using API’s Applications Layer APIsThe applications layer of XML Publisher allows ...
随机推荐
- iOS项目上传到AppStore步骤流程
1.登录developer.apple.com 2.点击member center后 进下图 3.点击certificates Identifiers进下图 4.点击Certificates进下图,首 ...
- iOS-代理反向传值<转>
在上篇博客 iOS代理协议 中,侧重解析了委托代理协议的概念等,本文将侧重于它们在开发中的应用. 假如我们有一个需求如下:界面A上面有一个button.一个label.从界面A跳转到界面B,在界面B的 ...
- gerrit添加新用户
默认gerrit的web服务端口为8080,通过apache的反向代理就可以使用标准的80(HTTP)来访问gerrit的web界面,在apache的配置文件httpd.conf添加如下反向代理和HT ...
- du df 查看文件和文件夹大小
http://www.cnblogs.com/benio/archive/2010/10/13/1849946.html du -h df -h du -h --max-depth=1 // 查看当 ...
- 基于git的工作流程
本文针对的是追求极致.快速的产品响应团队的.以下的观点和内容都是围绕这个主题,暂时不涉及个人学习和团队学习. 在说工作流程之间,想说一下我们平常工作中遇到的一些困惑或者说现象 在一个团队里,同时有好多 ...
- 用mciSendString做音乐播放器
音乐操作类 public class clsMCI { public clsMCI() { // // TODO: 在此处添加构造函数逻辑 // } //定义API函数使用的字符串变量 [Marsha ...
- OSX下VirtualBox安装CentOS
1.OSX上下载安装VirtualBox 2.新建虚拟机(所有选项默认即可) 3.启动虚拟机,选择CentOS安装镜像 CentOS-6.7-x86_64-minimal.iso 此处下载的是最小镜像 ...
- Nginx安装学习使用详细记录
选择Nginx的优点:Nginx 可以在大多数 Unix like OS 上编译运行,并有 Windows 移植版. Nginx 的1.4.0稳定版已经于2013年4月24日发布,一般情况下,对于新建 ...
- HBase 高性能加入数据 - 按批多“粮仓”式解决办法
摘要:如何从HBase中的海量数据中,以很快的速度的获取大批量数据,这一议题已经在<HBase 高性能获取数据>(http://www.cnblogs.com/wgp13x/p/42451 ...
- 数据结构--线段树--lazy延迟操作
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 53749 ...