Hello there, Hopefully someone can help - I have looked through the existing queries and can't just find what I'm after. I have posted this to users but to no avail, please could somebody confirm if this is a bug in the software or if I'm doing something incorrectly?
I have a main record with asociated files - the files are uploaded through my web app and are downloaded from the same page that lists the files in a dataTable. I have a series of commandLinks that display the file names - a user selects the file and it downloads. The problem I have is that when a user downloads a file then immediately trys to upload another, they are prompted to download the file that they have already previously downloaded. If however I replace the commandLinks for commandButtons the application behaves correctly. I have seen an associated link that mentions similar behaviour (http://blogs.sun.com/tor/entry/creating_downloadable_files), however I do not want to use the command buttons in this manner, and I use an actionListener rather than an action so I may retrieve information from the list of dynamically created files. I am not receiving any errors, just the strange behaviour with commandLinks. My code is as follows: public void downloadFile(ActionEvent ev) { UIData fileList = findParentHtmlDataTable(ev.getComponent()); AssociatedFile associatedFile = (AssociatedFile) fileList.getRowData(); String downloadPath = "download path retrieved here..."; try { byte[] fileData = InternalUtil.readFile(downloadPath); HttpServletResponse response = (HttpServletResponse) getFacesContext().getExternalContext().getResponse(); response.setHeader("Content-disposition", "attachment; filename=\"" + associatedFile.getName() + "\""); response.setContentLength(fileData.length); response.setContentType(associatedFile.getContentType()); ServletOutputStream out = response.getOutputStream(); out.write(fileData); getFacesContext().getApplication().getStateManager().saveSerializedView(getFacesContext()); getFacesContext().responseComplete(); } catch (FileSystemException e) { getFacesContext().addMessage("null", new FacesMessage("Error downloading file: " + e.getMessage())); } catch (IOException e) { getFacesContext().addMessage("null", new FacesMessage("Error downloading file: " + e.getMessage())); } } Any help would be greatly appreciated! Thanks in anticipation, Carl -- View this message in context: http://www.nabble.com/commandButton-behaviour-differs-to-commandLink-tf2387145.html#a6654728 Sent from the My Faces - Dev mailing list archive at Nabble.com.