使用Apache POI创建Excel工作簿时,Xpages ExtLib对话框出错
使用XPages ExtLib对话框使用Apache POI创建MS Excel时,我收到一个错误“更新某些页面时出错。Node.replaceChild的参数1不是对象”如果从XPage上的按钮执行导出,则导出工作正常。使用Apache POI创建Excel工作簿时,Xpages ExtLib对话框出错,xpages,lotus-domino,Xpages,Lotus Domino,使用XPages ExtLib对话框使用Apache POI创建MS Excel时,我收到一个错误“更新某些页面时出错。Node.replaceChild的参数1不是对象”如果从XPage上的按钮执行导出,则导出工作正常。 Domino9.0.1 FP8 请解释一下我在对话框中犯了什么错误? 谢谢 当对话框打开时,请怀疑faces上下文响应发生了变化。我对这些练习的长期建议是:创建一个JavaBean,将其添加为托管bean,以完成所有处理并调用类上的方法。灵感来源:谢谢你的建议,开始了我使用J
Domino9.0.1 FP8 请解释一下我在对话框中犯了什么错误? 谢谢
当对话框打开时,请怀疑faces上下文响应发生了变化。我对这些练习的长期建议是:创建一个JavaBean,将其添加为托管bean,以完成所有处理并调用类上的方法。灵感来源:谢谢你的建议,开始了我使用JavaBean的道路。
<?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>
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();
}