FileDownload PrimeFaces

0 respostas
Extreme_X

Olá galera estou com um problema com o prime faces. Estou tentando implementar o FileDownload e ele não funciona. Já fiz o debug do codigo e ele passa pelo construtor do ManagedBean e pelo get do StreamedContent. Segue o código:

public class SomeDownload {

private StreamedContent file;

public SomeDownload() throws FileNotFoundException {
		InputStream stream = new FileInputStream("D:\\15201\\scratch.mp3");
		file = new DefaultStreamedContent(stream);
}

public StreamedContent getFile() {
	return file;
}

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

pagina

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
      
<h:head>
	<style>
		html{font-size: 12px;}
	</style>
</h:head>

<h:body>
<h:form>

<p:commandLink id="scratch" value="Download">
	<p:fileDownload value="#{someDownload.file}"/>
</p:commandLink>

</h:form>
</h:body>


</html>

Se alguém souber solucionar isso, agradeço se puder compartilhar.

Criado 28 de setembro de 2011
Respostas 0
Participantes 1