为什么我的应用程序在 ssjs 脚本使用 facesContext.responseComplete(); 后几秒钟没有响应?

Why does my application become unresponsive for a few seconds after an ssjs script uses facesContext.responseComplete();?

我正在使用一些利用 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 不起作用。

感谢您的任何建议, ---丽莎&

将客户端 JS 调用 XSP.allowSubmit() 添加到您的按钮,以便在按下按钮后允许新的提交。

另请参阅此答案:whosebug.com/a/21931903/785061