I use the media primefaces tag to present pdf's but if the bean is @ViewScope
the stream is always null, why?
Asked
Active
Viewed 6,367 times
1
1 Answers
4
Because the desired JSF view state isn't available when the webbrowser is about to download the PDF in an entirely separate(!!) HTTP request. This is essentially exactly the same problem as with PrimeFaces <p:graphicImage>
as answered in the following questions:
- How to bind dynamic content using <p:media>?
- Display dynamic image from database with p:graphicImage and StreamedContent
Basically, you need to pass an identifier of the desired media file as <f:param>
and then create an entirely stateless managed bean which streams the desired DefaultStreamedContent
depending on the current request phase ID and the supplied request parameter.
-
This works fine on Opra, Edge, Chrome BUT NOT ON FIREFOX 60.0.2 - `Caused by: org.apache.catalina.connector.ClientAbortException: java.io.IOException`, why this is happening? – UHDante Oct 04 '18 at 08:19
-
OK -> https://stackoverflow.com/a/43163279/9112160 Solved my first problem, now I have on Firefox that `context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE` is always the same "6", no entering on the else to charge the data :( – UHDante Oct 04 '18 at 09:45
-
SOLVED -> https://support.mozilla.org/en-US/kb/use-adobe-reader-view-pdf-files-firefox. Seams my firefox wasent prepare to view PDF, by default it wanted to download... – UHDante Oct 04 '18 at 11:11