Galera não estou conseguindo aplicar o exemplo do <p:fileDownload /> do Primefaces, vejam o erro que está acontecendo:
Erro
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
root cause
java.lang.NullPointerException
org.primefaces.component.filedownload.FileDownloadActionListener.processAction(FileDownloadActionListener.java:53)
javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:772)
javax.faces.component.UICommand.broadcast(UICommand.java:300)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.14 logs.
Apache Tomcat/7.0.14
Meu index.xhtml
<p:tab title="Controle">
<h:panelGrid columns="2" cellpadding="5">
<p:commandLink ajax="false" title="Download">
<p:graphicImage value="/imagens/pdf.png" />
<p:fileDownload value="#{documentacaoController.file}" />
</p:commandLink>
<h:outputText value="Arquivo" />
</h:panelGrid>
</p:tab>
Meu Controller
@ManagedBean
@SessionScoped
public class DocumentacaoController {
private StreamedContent file;
public StreamedContent FileDocumentacaoController() {
InputStream stream = this.getClass().getResourceAsStream("C:/teste/CeWolf.pdf");
file = new DefaultStreamedContent(stream, "application/pdf", "downloaded_CeWolf.pdf");
return file;
}
public StreamedContent getFile() {
return file;
}
public void setFile(StreamedContent file) {
this.file = file;
}
}
Alguém poderia me ajudar, pois estou batendo cabeça e não conseguigo solucionar o problema.