为什么Primefaces Media Dynamic在视图范围内不起作用? [英] Why primefaces media dynamic doesn't work in view scope?
问题描述
我使用media primefaces标签显示pdf,但是如果bean是@ViewScope
,则流始终为null,为什么?
因为当Web浏览器将要在完全独立的(!!)HTTP请求中下载PDF时,所需的JSF视图状态不可用.本质上,与PrimeFaces <p:graphicImage>
完全相同,是在以下问题中回答的问题:
基本上,您需要将所需媒体文件的标识符作为<f:param>
传递,然后创建一个完全无状态的受管bean,该bean根据当前请求阶段ID和所提供的请求参数来流传输所需的DefaultStreamedContent
.>
I use the media primefaces tag to present pdf's but if the bean is @ViewScope
the stream is always null, why?
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.
这篇关于为什么Primefaces Media Dynamic在视图范围内不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!