Why primefaces media dynamic doesn't work in view scope?

泄露秘密 提交于 2019-12-24 14:54:20

问题


I use the media primefaces tag to present pdf's but if the bean is @ViewScope the stream is always null, why?


回答1:


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.



来源:https://stackoverflow.com/questions/25424713/why-primefaces-media-dynamic-doesnt-work-in-view-scope

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!