How to add & display binaries on PF Galleria?

157 Views Asked by At

As the PF demo of GraphicImage:

https://www.primefaces.org/showcase/ui/multimedia/graphicImage.xhtml?jfwid=a0c1a

(Asked on PF Forum) Using: GraphicImage I could add a single binary image by:

<p:graphicImage value="#{nOTiFYMotorcycleController.graphicImage}" stream="false"/>

public InputStream getGraphicImage() throws IOException {

   ...
   
   return Files.newInputStream(Paths.get(stringBuffer.toString()));
}

I can't see how to add a InputStream/byte[] in Galleria - Basic. I want to display a number of Images within a <List>?

I have also tried Use of p:graphicImage in ui:repeat or p:dataTable

What I really want to do is as PF Galleria - Basic:

https://www.primefaces.org/showcase/ui/multimedia/galleria/basic.xhtml?jfwid=a0c1a

With all my Images in a 'different location' say 2 x i.e.:

/Users/NOTiFY/IdeaProjects/NOTiFYmoto/images/moto/MotoGuzzi/2023/V85/TT/gu9032278eun02-01-m.webp
/Users/NOTiFY/IdeaProjects/NOTiFYmoto/images/moto/MotoGuzzi/2023/V85/TT/gu9032278eun01-01-m.webp
1

There are 1 best solutions below

0
Frank Cornelis On

Why don't you serve your images via a plain Servlet?

<p:galleria value="#{bean.images}" var="image">
    <p:graphicImage value="/myImageServlet/#{image.id}"/>
</p:galleria>

And have a servlet like:

@WebServlet("/myImageServlet/*")
public class MyImageServlet extends HttpServlet {
  // parse image ID from request.getRequestURI()
  // load and serve
}