原文地址: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. iOS 自定义Actionsheet

    自定义的Actionsheet效果如下 自定义的思路 1.在window上添加两个图层,背景层和功能层,如下图 2.设置背景层的背景色和透明度,并在背景层上添加点击事件 3.将自定义的view添加为功 ...

  2. Regex Expression的资料和笔记整理

    维基百科:http://en.wikipedia.org/wiki/Regular_expression 正则表达式在线测试:http://tool.chinaz.com/regex/ 正则表达式,常 ...

  3. Android中ListView 控件与 Adapter 适配器如何使用?

    一个android应用的成功与否,其界面设计至关重要.为了更好的进行android ui设计,我们常常需要借助一些控件和适配器.今天小编在android培训网站上搜罗了一些有关ListView 控件与 ...

  4. Memcache笔记05-Memcache安全性

    Memcache服务器端都是直接通过客户端连接后直接操作,没有任何的验证过程,这样如果服务器是直接暴露在互联网上的话是比较危险,轻则数据泄露被其他无关人员查看,重则服务器被入侵,因为Mecache是以 ...

  5. 三种另外的循环 while{} 和do{}while{}还有switch case

    while的写法 var i=0; while(i<5){ document.write("12378<br />");  i++;} while(true)-- ...

  6. Html 的实体字符大全

    HTML特殊符号对照表.常用的字符实体 最常用的字符实体 显示结果 描述 实体名称 实体编号   空格     < 小于号 < < > 大于号 > > & ...

  7. 从源码分析 Spring 基于注解的事务

    在spring引入基于注解的事务(@Transactional)之前,我们一般都是如下这样进行拦截事务的配置: <!-- 拦截器方式配置事务 --> <tx:advice id=&q ...

  8. js模板

    作用 适合用于定义模板(模板容器),不解析(渲染/执行). 为什么这样使用 在js里面,经常需要使用js往页面中插入html内容.比如这样: var number = 123; $('#d').app ...

  9. Vrrp协议

    一.简介 VRRP(Virtual Router Redundancy Protocol)协议是用于实现路由器冗余的协议,最新协议在RFC3768中定义,原来的定义RFC2338被废除,新协议相对还简 ...

  10. POJ3648 A Simple Problem with Integers(线段树之成段更新。入门题)

    A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 53169 Acc ...