permaculture playing cards*
The moose likes HTML, CSS and JavaScript and the fly likes Enable/disable buttons - File download(CSV) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Enable/disable buttons - File download(CSV)" Watch "Enable/disable buttons - File download(CSV)" New topic
Author

Enable/disable buttons - File download(CSV)

sanju juhi
Greenhorn

Joined: Aug 02, 2007
Posts: 2
Hi All,

I have a JSP page where I have a submit button. When user click the submit button, query gets executed in the backend. I need to disable a button till the query gets executed and displayed in 'csv' format. After that i again want to enable the button.

Disabling the button is not a problem, but I am not able to enable the button once the download is complete since once we display the Save As dialog box for CSV download, the control is with the browser.

Is there any way I can enable the button again without manually refreshing the page..
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
One of the things we do is set a timer on the button so that the user cannot be accidentally pressed again for x seconds. You could get your jsp to open a _blank page that contains the execution for the download and only enable the download button when the page closes.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

This seems a tad odd. If your submit is a typical GET/POST for a form to the server then your page is going to reload no matter what. When the page refreshes, assuming your server returns to the same page, your button will be enabled because that is the default behavior when the page first loads.

If you are doing a different type of submit then you need to tell us.


GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60998
    
  65

If the content dispostion is set up as an attachment, the current page will not be replaced. But there is no way to detect when the user saves the file to the disk.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sanju juhi
Greenhorn

Joined: Aug 02, 2007
Posts: 2
Hi All,

Thanks a lot for the help.....

Ok....Actually what we have in the web page exactly is "Save a Copy" button...

1) The user clicks on the "Save a Copy" button.
2) The button should be disabled..
3) The query will fetch million of records from the database(This will take few minutes)..So we dont want the user to click the button again while processing..
4) Once the processing is done....we open a CSV file from the servlet program using :

res.setContentType("application/text;name=" + "REPORT.CSV");
res.setHeader("Content-Disposition", "attachment; filename=" + "REPORT.CSV");

5) By doing this...the control goes to the browser and I am not able to enable the button again once the download completes...

Can anybody please help me out .....
[ August 05, 2007: Message edited by: sanju juhi ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60998
    
  65

I repeat:

Originally posted by Bear Bibeault:
But there is no way to detect when the user saves the file to the disk.


Asking the question over again will not change the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enable/disable buttons - File download(CSV)