Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not possible to use <code>&lt;p:graphicImage&gt;</code> this way. You should rather iterate over a collection of unique image identifiers, not over a collection of <code>StreamedContent</code>. Those unique image identifiers have then to be passed as a <code>&lt;f:param&gt;</code> to <code>&lt;p:graphicImage&gt;</code> which in turn will generate the right URLs for the browser.</p> <pre><code>&lt;ui:repeat value="#{data.imageIds}" var="imageId"&gt; &lt;p:graphicImage value="#{imageStreamer.image}"&gt; &lt;f:param name="id" value="#{imageId}" /&gt; &lt;/p:graphicImage&gt; &lt;/ui:repeat&gt; </code></pre> <p>Your <code>#{data}</code> managed bean must just have a:</p> <pre><code>private List&lt;Long&gt; imageIds; // +getter </code></pre> <p>The <code>#{imageStreamer}</code> should be a separate application scoped managed bean which look basically like this:</p> <pre><code>@ManagedBean @ApplicationScoped public class ImageStreamer { @EJB private ImageService service; public StreamedContent getImage() throws IOException { FacesContext context = FacesContext.getCurrentInstance(); if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) { // So, we're rendering the view. Return a stub StreamedContent so that it will generate right URL. return new DefaultStreamedContent(); } else { // So, browser is requesting the image. Get ID value from actual request param. String id = context.getExternalContext().getRequestParameterMap().get("id"); Image image = service.find(Long.valueOf(id)); return new DefaultStreamedContent(new ByteArrayInputStream(image.getBytes())); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload