I'm programming a <p:lightBox>
with a streamed <p:media>
to preview external PDFs.
It works fine but i'm getting a little handicap.
When the pdf dialog is rendered it shows (on mouse over) one Header where it always display the same title: "dynamiccontent.properties".
Is there an attribute or something that I can override to customize it?
JSP code:
<p:lightBox>
<h:outputLink value="#" title="#{myDoc.fileName}">
<i class="fa fa-eye" aria-hidden="true"></i>
</h:outputLink>
<f:facet name="inline">
<p:media value="#{documentController.stream}" width="1100px" height="600px" player="pdf">
<f:param name="idStore" value="#{myDoc.idStore}" />
</p:media>
</f:facet>
</p:lightBox>
Thanks for your time.
This happend just because the DefaultStreamedContent lost the file's Propertis, this means Title and name.
It must to be used a servlet to set the header, contenttype and file´s name. while it is downloaging:
The method could be in this way, the servlet with the declared name it's invoked with
@webservlet
:The view works with the primeface´s component:
<p:media />
:This seems to be a bug in Primefaces. Checkout Primefaces version 6.1 as they seem to have fixed this issue here. Then, setting the content name in
DefaultStreamedContent
worksMy
<p:media>
in xhtml:And the rendered
<p:media>
looks like this:Then both the pdf viewer title and the download file name in Chrome are "document.pdf".
I have encountered the same problem when using google chrome.
The header does not appear in IE 11.
(I'm only using IE 11 and Google Chrome so I don't know what this looks like on other browser)
This is what a rendered
media
with a streamed value will look like:/projectName/javax.faces.resource/dynamiccontent.properties.xhtml
comes fromDynamicContentSrcBuilder#build(resourcePath)
I have tried:
1. setting name in
DefaultStreamedContent
this does not seem to work. name becomes null in
MediaRenderer#encodeEnd
so the name is not added in thesrc
.2. override
MediaRenderer#encodeEnd
and add a fixed value name(Test.pdf)This also did not worked. The lightBox opens but can't display the pdf file.
3. override
MediaRenderer#encodeEnd
and replace the value of "dynamiccontent.properties" in thesrc
with the value fromtitle
which is set in xhtml.MediaRenderer#encodeEnd
xhtml
redered
media
will look something like this.This works but only on
StreamedContent
. following is a screenshot of the pdf header.Note that ".xhtml" is needed. It will not work without it.
Hope this helps.