In order to use the lightbox, I need a link to the image as generated by <p:graphicImage>.
Ultimately, the HTML should look like this:
<a href="image.jpg" data-lightbox="bilder">
<img src="image.jpg" />
</a>
This is my JSF attempt so far:
<h:outputLink data-lightbox="bilder" value="???">
<p:graphicImage value="#{imageStreamer.image}">
<f:param name="imageId" value="#{gameReader.game.cover.id}"/>
</p:graphicImage>
</h:outputLink>
How do I get the concrete URL of <p:graphicImage> returning StreamedContent so that I can use it in my link?
Have suggested a solution to this question here.
Long story short, you can use the
getImageSrcmethod of theGraphicImageRendererin order to get the image URI.First step is extending the
GraphicImageRendererto publish the protectedgetImageSrcmethod:The we need a method in managed bean that enables us use the
getPublicImageSrcmethod:Finally we bind the
p:graphicImagecomponent to an arbitrary variable and invokemyBean.getImgUrito get the Uri for any purpose: