如何更新 fileDownload 上的 dataTable 组件并且 ajax 为 false
How to update dataTable component on fileDownload and ajax is false
在用户点击 primefaces 中的 fileDownload 后,我需要你的帮助来更新 dataTable 组件。案例是用户点击下载文件,它会下载文件,同时,它会更新dataTable中的count列。 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为false,所以dataTable没有更新,那么如何执行上面的代码呢?如果我启用 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>
在用户点击 primefaces 中的 fileDownload 后,我需要你的帮助来更新 dataTable 组件。案例是用户点击下载文件,它会下载文件,同时,它会更新dataTable中的count列。 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为false,所以dataTable没有更新,那么如何执行上面的代码呢?如果我启用 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>