Display dynamic image from database or remote source with p:graphicImage and StreamedContent

前端 未结 4 1713
我寻月下人不归
我寻月下人不归 2020-11-21 11:10

I\'m trying to display image bytes which is saved in database as a StreamedContent in the as follows:



        
4条回答
  •  既然无缘
    2020-11-21 11:56

    The answer from BalusC is (as usual) the correct one.

    But keep one thing (as already stated by him) in mind. The final request is done from the browser to get the URL from the constructed tag. This is not done in a 'jsf context'.

    So if you try to e.g. access the phaseId (logging or whatever reason)

    context.getCurrentPhaseId().getName()
    

    This will result in a NullPointerException and the somehow misleading error message you will get is:

    org.primefaces.application.resource.StreamedContentHandler () - Error in streaming dynamic resource. Error reading 'image' on type a.b.SomeBean
    

    It took me quite some time to figure out what was the problem.

提交回复
热议问题