I want to download a file with primefaces, everything works but nothing happens on the browser.
here is my xhtml:
Code: Select all
<p:commandLink title="Download file" action="#{msgBoxBean.selectMessage}" process="@this" update="@none" >
<img src="#{resource['img:icon_document_flat_download.gif']}" alt="#{msg['mcn.inbox.flat.file.download']}}"/>
<f:setPropertyActionListener target="#{msgBoxBean.selectedMessage}" value="#{message}" />
<p:fileDownload value="#{msgBoxBean.downloadPrincipalFile}"/>
</p:commandLink>
here is my bean (managed bean - view scoped) I also use CDI bean and conversationScoped but it is also not working
Code: Select all
@ManagedBean(name = "msgBoxBean")
@ViewScoped
public class MsgBoxBean implements Serializable {
Logger logger = LoggerFactory.getLogger(MsgBoxBean.class);
private Message selectedMessage;
public MsgBoxBean() {
}
@PostConstruct
public void initServices() {
}
public StreamedContent getDownloadPrincipalFile() {
logger.debug("start getDownloadPrincipalFile");
ByteArrayInputStream content = null;
/// some stuff to create mly content
DefaultStreamedContent file = new DefaultStreamedContent(content, "text/plain", "currentFile.txt");
}
throw new AbortProcessingException();
} catch (XPathExpressionException ex) {
throw new DataAccessException("An unexpected exception occured while retrieve the inputStream from the following archivedId: " + selectedFile.getArchiveId(), ex);
} catch (IOException ex) {
throw new DataAccessException("An unexpected exception occured while retrieve the inputStream from the following archivedId: " + selectedFile.getArchiveId(), ex);
}
}
public void selectMessage() {
}
public Message getSelectedMessage() {
return selectedMessage;
}
public void setSelectedMessage(Message selectedMessage) {
logger.debug("set the selected message for download");
this.selectedMessage = selectedMessage;
}
}
Can you help me!
Jamila