Primefaces媒体显示旧的PDF

时间:2014-06-25 15:47:24

标签: caching jsf-2 primefaces

我有一个PDF文档,它是根据应用程序中包含的数据生成的,这个pdf文档是使用媒体组件primefaces显示的,一切正常,但是为了对数据源进行更改,我仍然显示旧文档。 到目前为止,我已经通过清除浏览器缓存解决了问题,但是这个问题怎么可能解决这个问题呢?

     <p:media value="#{listadoFacturasMB.fileDownload}" width="100%"  height="600px" player="pdf">
                    <f:param name="id" value="#{listadoFacturasMB.selectedFactura.idFactura}" />
     </p:media>  

2 个答案:

答案 0 :(得分:3)

I have tested it with primefaces 5.3 and the media tag in there has an attribute cache which has true as default value, set it to false and it will always load the file from the server instead of cache

答案 1 :(得分:2)

我在这里找到的部分答案: link 我只是强制组件总是有不同的id,虽然它是同一个文件。这就是xhtml中的代码:

<p:media value="#{serviciosMB.servicioDownload}" width="100%"  height="600px" player="pdf">
                    <f:param name="id" value="#{serviciosMB.idFile}" />
</p:media>

支持bean:

public String getIdFile() {
    return  java.util.UUID.randomUUID().toString();
}