This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
How can i do this? If this is not possible, can i do some simulation so that the window closes on some logical event?
When the compiler's not happy, ain't nobody happy.
The file to be downloaded is not static, it is created after fetching a lot of data from the DB and then processing it. This takes some time, hence in order to not keep the user waiting, i am using a popup window. The user can then continue his work on the main window and navigate away from that page too, being prompted for the download after the file is ready.
Will this not lead to confusion to the user? I mean, as i said, the creation of the file to be downloaded can take anywhere between 2-10 minutes, so if we close the popup window as soon as the link is created, the user has to simply wait and watch. Also, i cannot understand how the file will be sent if the popup is closed, the data is written to the response stream of the wndow, right?
Try this out. After calling "response.flushBuffer();" method it can be considered that the generation and prompt for download is complete. So user already has the download or "save as" windows opened, making it simply possible to close the popup without affecting rest of the operation.
Add below line after "response.flushBuffer();"
Here is the code for "closeWindow.htm"
Note that "window.close()" method can only be used with pop-ups or winnows opened with "window.open()" method.
Write back if this fail.
PS - Raj was talking about the window.print() method used to take a printout of a page using a Printer. So I don't think that method will meet your requirements.
I Tried this method. The popup window closes, but before the download popup appears to the user. I tried to put delays before "response.sendRedirect()", but still it seems that the sendRedirect method does not let the download popup to appear before it executes.!!