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;
}
}