You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Fan Shao <ra...@yahoo.com> on 2008/10/23 14:15:14 UTC

Events not removed after it's fired

Hi,

I have a JSF page containing a few tabs, a table (showing a list of items)
and a 'download' button. The 'download' button is there to allow the user to
download the contents of the table as a txt file. 

The problem is when the button is hit, the user gets the browser's dialog
prompting to 'save' or 'open' as expected, but after that all the other
buttons/links on the page would result in the same 'save/open' dialog again,
unless he closes the browser and start a new session.

The code in the 'download' button's handler is like this:

public void doSaveList() {

                // other code ...

		HttpServletResponse response = (HttpServletResponse)
FacesContext.getCurrentInstance().getExternalContext().getResponse();
		response.setContentType(this.fileFormat.getMineType());
		if (this.fileName == null || this.fileName.trim().length() == 0) {
			this.fileName = "ExportedList";
		}
		response.setHeader("Content-disposition", "attachment; filename=" +
this.fileName + this.fileFormat.getFileNameExtension());

		try {
			response.getOutputStream().write(bytes);
			response.getOutputStream().flush();
			response.getOutputStream().close();
			FacesContext.getCurrentInstance().responseComplete();
		} catch (IOException e) {
			e.printStackTrace();
			this.showErrorPage("Problem saving to File '" + this.fileName + "'");
		}
	}


Does anyone has any idea about the cause of this? Thanks in advance.
-- 
View this message in context: http://www.nabble.com/Events-not-removed-after-it%27s-fired-tp20129703p20129703.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.