This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enable/disable buttons - File download(CSV)

 
sanju juhi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64609
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sanju juhi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64609
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic