当使用XPages ExtLib对话框使用Apache POI创建MS Excel时,我收到错误“更新部分页面时发生错误.Node.replaceChild的参数1不是对象”如果从一个对象执行,导出工作正常XPage上的按钮 Domino 9.0.1 FP8 请解释我对话的错误? 感谢
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.resources>
<xp:script
src="/CreateStream.jss"
clientSide="false">
</xp:script>
</xp:this.resources>
<xp:table>
<xp:tr>
<xp:td>
<xp:button
value="Test Export"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:CreateWorkbookStream();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:td>
<xp:td></xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:button
value="Open Dialog"
id="button3">
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[XSP.openDialog("#{id:dialog1}");]]></xp:this.script>
</xp:eventHandler></xp:button></xp:td>
<xp:td></xp:td>
</xp:tr>
</xp:table>
<xp:br></xp:br>
<xe:dialog id="dialog1">
<xp:panel>
<xp:table>
<xp:tr>
<xp:td>
<xp:button
value="Test Export"
id="button2">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:CreateWorkbookStream();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:td>
<xp:td></xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:button
value="Close Dialog"
id="button4">
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[XSP.closeDialog("#{id:dialog1}");]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:td>
<xp:td></xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xe:dialog>
</xp:view>
JavaScript库
function CreateWorkbookStream(){
importPackage(java.lang);
importPackage(org.apache.poi.hssf.usermodel);
importPackage(org.apache.poi.hssf.util);
var sheetName = "sheet1";
//Create a new workbook object from the poi library
var wb:HSSFWorkbook = new HSSFWorkbook();
//Create additional sheets using same sytnax and different sheet name
var sheet1:HSSFSheet = wb.createSheet(sheetName);
//Create row
var row:HSSFRow = sheet1.createRow(0);
var cell:HSSFCell = row.createCell((java.lang.Integer)(0));
cell.setCellValue("One");
//Create file name
var workbookName = "exptest"
var fileName = workbookName+".xls";
//Write output
// The Faces Context global object provides access to the servlet environment via the external content
var extCont = facesContext.getExternalContext();
// The servlet's response object provides control to the response object
var pageResponse = extCont.getResponse();
//Get the output stream to stream binary data
var pageOutput = pageResponse.getOutputStream();
// Set the content type and headers
pageResponse.setContentType("application/x-ms-excel");
pageResponse.setHeader("Cache-Control", "no-cache");
pageResponse.setHeader("Content-Disposition","inline; filename=" + fileName);
//Write the output, flush the buffer and close the stream
wb.write(pageOutput);
pageOutput.flush();
pageOutput.close();
// Terminate the request processing lifecycle.
facesContext.responseComplete();
}