我需要您的帮助来更新数据词组件后用户单击PrimeFaces中的FileDownload。情况是用户将单击下载文件,并将下载文件,同时,它将更新DataTableThe中的计数列。DataTable中下载文件的JSF代码为:
<p:column headerText="View">
<p:commandLink id="exporter" actionListener="#{exstaff.GeneratePDF}" ajax="false">
<h:graphicImage name="/images/PDF.png"/>
<p:fileDownload value="#{exstaff.pdfFile}"/>
</p:commandLink>
</p:column>
在GeneAreTPDF方法中,我允许用户下载一个PDF文件,但是,在GeneratePDF()方法的末尾,我可以使用代码更新数据词:
。RequestContext context = RequestContext.getCurrentInstance();
context.update("@form");
但是,由于Ajax是错误的,因此未更新数据,因此如何执行上述代码?如果我启用Ajax,下载文件将无法工作。
您可以添加一个远程命令:
<p:column headerText="View">
<p:commandLink id="exporter" actionListener="#{exstaff.GeneratePDF}" ajax="false"
onstart="callRC()">
<h:graphicImage name="/images/PDF.png"/>
<p:fileDownload value="#{exstaff.pdfFile}"/>
</p:commandLink>
和要更新的表格:
<form id="yourForm">
<p:remoteCommand name="callRC" update="@form"/>
</form>