PrimeFaces filedownload questions

UI Components for JSF
Post Reply
akaine
Posts: 14
Joined: 31 Mar 2010, 20:47

31 Mar 2010, 21:53

Hi

I've got a couple of questions regarding this component.

1. Can I access external (out of the app context) files with this component?
2. If yes, how should I modify the example code to achieve this (how to set the file path?, etc.)?

Code: Select all

import java.io.InputStream;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;

public class FileDownloadController {

	private StreamedContent file;
	
	public FileDownloadController() {
		InputStream stream = this.getClass().getResourceAsStream("somefile.xls");
		file = new DefaultStreamedContent(stream, "application/vnd.ms-excel", "somefile.xls");
	}
	
	public StreamedContent getFile() {
		return file;
	}

	public void setFile(StreamedContent file) {
		this.file = file;
	}
}
Thanks in advance

akaine
Posts: 14
Joined: 31 Mar 2010, 20:47

01 Apr 2010, 03:56

Forget it, wrote my own downloader using direct JSF response alteration approach...
Dev. config: PrimeFaces 5.0, Mojarra JSF 2.2.x, WildFly 8.1.0 Final

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

05 Apr 2010, 02:19

Yes to both, the idea of filedownload is to help you not to write your own handler and provide a generic one.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 35 guests