Commit 41ba50bd by Antti Tönkyrä

printage

1 parent b6312dc5
......@@ -16,7 +16,7 @@
<ui:define name="content">
<h:form>
<p:commandButton rendered="#{cardMassPrintView.file!=null}" id="downloadLink" value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)" icon="ui-icon-arrowthichk-s">
<p:fileDownload value="#{cardMassPrintView.file}" />
<p:fileDownload value="#{cardMassPrintView.streamedFile}" />
</p:commandButton>
</h:form>
</ui:define>
......
......@@ -8,6 +8,9 @@ import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import fi.insomnia.bortal.beans.CardPrintBeanLocal;
import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.web.cdiview.user.UserCartView;
......@@ -29,6 +32,7 @@ public class CardMassPrintView implements Serializable {
@EJB private CardPrintBeanLocal cardPrintBean;
private File file;
private StreamedContent streamedFile;
public CardMassPrintView() {
// TODO Auto-generated constructor stub
......@@ -49,6 +53,8 @@ public class CardMassPrintView implements Serializable {
FileOutputStream fostream = new FileOutputStream(file);
fostream.write(printout);
fostream.close();
setStreamedFile(new DefaultStreamedContent(new FileInputStream(this.file)));
} catch(Exception e) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
}
......@@ -69,4 +75,12 @@ public class CardMassPrintView implements Serializable {
public void setFile(File file) {
this.file = file;
}
public StreamedContent getStreamedFile() {
return streamedFile;
}
public void setStreamedFile(StreamedContent streamedFile) {
this.streamedFile = streamedFile;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!