I´m currently try to create a PDF (which already working).
I´m creating the PDF from a URL.
So if I change something in the content from this URL and open the p:dialog again, also my PDF should be refreshed....
But it seems the content in the dialog is not updated. The pdf generation function is called, but it seems it´s still caching on client side?
Did I forgot something?
Function to call the PDF creation:
Code: Select all
<h:form id="myForm">
<p:commandButton value="Show Preview"
update=":previewDialogForm" ajax="true" resetValues="true"
actionListener="#{generatePdfDocumentDesignerController.createPDF()}"
oncomplete="PF('previewWidgetDlg').show();">
<p:resetInput target=":previewDialogForm" />
</p:commandButton>
</h:form>
Code: Select all
<h:form id="previewDialogForm">
<p:dialog id="previewDialog" widgetVar="previewWidgetDlg"
appendTo="@(body)" header="Vorschau" showHeader="true"
maximizable="true" contentWidth="80%" contentHeight="80%"
height="85vh" width="85vw" minimizable="false" dynamic="true"
modal="true" resizable="false" closable="true" closeOnEscape="true">
<pe:documentViewer id="generatedPdf"
style="height: 83vh; width: 82vw" zoom="100" cache="false"
value="#{generatePdfDocumentDesignerController.pdfFile}" />
<f:facet name="footer">
<div class="EmptyBox2"></div>
<div class="Fright">
<p:commandButton id="cancelBtn" value="Abbrechen"
styleClass="RaisedButton" style="margin-right: 15px;"
icon="fa fa-window-close" onclick="PF('previewWidgetDlg').hide()"
type="button" />
</div>
<div class="EmptyBox2"></div>
</f:facet>
</p:dialog>
</h:form>
Code: Select all
@Named
@ApplicationScoped
public class GeneratePdfDocumentDesignerController implements Serializable {
...
public void createPDF() {
FacesContext facesContext = FacesContext.getCurrentInstance();
try {
String url = createUrl();
pdfFile = null;
PipedOutputStream os = new PipedOutputStream();
PipedInputStream is = new PipedInputStream(os);
managedExecutorService.submit(() -> {
try {
PdfRendererBuilder builder = new PdfRendererBuilder();
XRLog.setLevel(XRLog.CSS_PARSE, Level.SEVERE);
builder.withUri(new URL(url).toString());
builder.toStream(os);
builder.run();
os.close();
} catch (IOException e) {
LOGGER.error(ExceptionUtils.getFullStackTrace(e));
}
});
pdfFile = new DefaultStreamedContent(is, "application/pdf");
}
catch (Exception e) {
ErrorMessage.showErrorMessage();
}
facesContext.responseComplete();
LOGGER.info("END createPDF");
}