Code: Select all
@ManagedBean(name = "DownloadTokenController")
@SessionScoped
public class DownloadTokenController {
@EJB
private UserDataService userDataService;
private StreamedContent file;
@PostConstruct
public void init() {
UserData userData = userDataService.getUserData();
XMLOutputter printer = new XMLOutputter(Format.getPrettyFormat());
InputStream in = IOUtils.toInputStream(printer.outputString(userDataService.exportAccessTooken(userData)));
setFile(new DefaultStreamedContent(in, "text/xml", "token." + "extension"));
}
public void setFile(StreamedContent file) {
this.file = file;
}
public StreamedContent getFile() {
System.out.println("DownloadTokenController getFile");
return file;
}
I use this to try to download the file.
Code: Select all
<p:commandButton value="Velg rolle" id="selectRole" action="#{ChooseExportController.download}">
<p:fileDownload value="#{DownloadTokenController.file}" contentDisposition="attachment"/>
</p:commandButton>
When I click the button nothing happends, no error message nothing.
What could be the problem? Is there any other good way to download generated files using JFS?