0
votes

I am using some code that utilizes poi functionality to output the content of a view to an excel spreadsheet. The spreadsheet is created when a user clicks on a button. The button contains ssjs code. The final calls to actually output the formatted spreadsheet are as follows:

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();

.........set some scope variables ........

print("about to reload page");*
context.reloadPage();

My button is set to perform a Full Update. The problem is that the application becomes unresponsive for a few seconds after the spreadsheet is produced. I want to reload the page and change the visibility of some panels. A manual refresh of the page works. From what I have read, I think the facesContext.responseComplete() is causing this behavior, but I need it to publish the spreadsheet. In the example above the print statement successfully prints to the console but the reloadPage does not work.

Thanks for any advice, ---Lisa&

1
Add the client-side JS call XSP.allowSubmit() to your button in order to allow new submits after pressing the button. See this answer: stackoverflow.com/a/21931903/785061 - Per Henrik Lausten
That did the trick. Thanks. - user4920643
Great to hear. I added my comment as an answer that you can accept. - Per Henrik Lausten

1 Answers

1
votes

Add the client-side JS call XSP.allowSubmit() to your button in order to allow new submits after pressing the button.

Also see this answer: stackoverflow.com/a/21931903/785061