我正在使用一些利用poi功能的代码将视图内容输出到Excel电子表格。当用户点击按钮时会创建电子表格。该按钮包含ssjs代码。实际输出格式化电子表格的最终调用如下:
var filename = "FallTeacherAssignments.xls";
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();
.........设置一些范围变量........
print("about to reload page");*
context.reloadPage();
我的按钮设置为执行完整更新。问题是应用程序在生成电子表格后几秒钟内没有响应。我想重新加载页面并更改某些面板的可见性。手动刷新页面有效。 根据我的阅读,我认为facesContext.responseComplete()导致了这种行为,但我需要它来发布电子表格。在上面的示例中,print语句成功打印到控制台,但reloadPage不起作用。
感谢您的任何建议, ---莉莎&安培;
答案 0 :(得分:1)
将客户端JS调用XSP.allowSubmit()添加到按钮,以便在按下按钮后允许新提交。