I have a Bean which has a List of Objects, containing StreamedContent Objects (Primefaces Type) which represent Images in a Database. Now I want to iterate over this list in
I broke my head on this one for a day or so, but I found a solution!
JSF:
<ui:repeat value="#{bean.images}" var="imageID">
<p:graphicImage value="#{bean.image}">
<f:param name="imageID" value="#{imageID}" />
</p:graphicImage>
</ui:repeat>
Managed bean:
public List<String> getImages(){
List<String> l = new ArrayList<String>();
for(Theme t:themeFacade.findAll())
l.add(t.getId().toString());
return l;
}
public StreamedContent getImage(){
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest myRequest = (HttpServletRequest) context.getExternalContext().getRequest();
String imageID = (String) myRequest.getParameter("imageID");
return new DefaultStreamedContent(new ByteArrayInputStream(themeFacade.find(Long.parseLong(imageID)).getImage()));
}