Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces media show old PDF

I have a PDF document that is generated from the data contained in the application, this pdf document is displayed using the media component primefaces, everything works fine, but to make changes to the data source I still shows the old document. So far I have solved by clearing the browser cache, but how could this problem solucioanr programming?

     <p:media value="#{listadoFacturasMB.fileDownload}" width="100%"  height="600px" player="pdf">
                    <f:param name="id" value="#{listadoFacturasMB.selectedFactura.idFactura}" />
     </p:media>  
like image 353
meyquel Avatar asked Jun 25 '14 15:06

meyquel


2 Answers

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

like image 175
Imran Khurram Avatar answered Oct 26 '22 11:10

Imran Khurram


Part of the answer I found here: link I just had to force the component that always had a different id though it were the same document. That's what this code in xhtml:

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

backing bean:

public String getIdFile() {
    return  java.util.UUID.randomUUID().toString();
}
like image 32
meyquel Avatar answered Oct 26 '22 11:10

meyquel