Whenever you submit a form to download a file the response sent back is a file. In this case the setter called after the method which does the download has no effect.
if(form.getDownloadForm != null && form.getDownloadForm.equals("Y")) { downloadForm(form, request); //The Below Setter has No Effect form.setDownloadForm("Y"); }
class RegisterForm() { public String downloadForm; public void setDownloadForm(String p_download) { this.downloadForm= p_download; } public String getDownloadForm() { return downloadForm; } }
The Setter had no effect since the request sent to the downloadForm(form, request); will end up with response of file download and not response which has new values to form set by setter(in our case downloadForm(form, request)) and Page reload.
There are 2 simple fix for this.
Fix 1
One simple fix is to set form hidden property in java script to N after the form get submitted. Note though the form is submitted it is not reloaded with new response since the response sent back is a file.
The Page will be reloaded only when response is sent back to the same URL of browser. Not to the browser as file.
function downloadWFSetup(pWaterfallId) { $('#downloadForm').val('Y'); document.WaterfallTriggerForm.submit(); //This part of code runs even after the form submission since the //response sent is file which does not require page reload $('#downloadForm').val('N'); }
In our case the page is not going to get reloaded so the java script continues its execution even after form submission setting property of downloadForm to N.
Fix 2
The Other way is to send request in Link with downloadForm=Y. In this case there is no need to to reset the form values as we get the values by request.getParameter() Method.