Using the code below I can’t get the image in the web page. I’m not sure if I understand the documentation in the right way and I’m not able to find any problem with this code.
BEAN
@ManagedBean(name = "imageBean")
@RequestScoped
public class ImageBean {
public void paint(OutputStream os, Object data) throws IOException {
BinaryContent content = (BinaryContent) data;
BufferedImage image = ImageIO.read(new ByteArrayInputStream(content.getContent()));
ImageIO.write(image, "jpg", os);
}
}
PAGE
<rich:dataTable value="#{dataProviderBean.aoRequests}" var="item">
<f:facet name="noData">No messages are available.</f:facet>
...
<rich:column>
<f:facet name="header">Image data</f:facet>
<rich:list value="#{item.imageContents}" var="content">
<a4j:mediaOutput element="img" cacheable="false" session="false"
createContent="#{imageBean.paint}" value="#{content}" />
</rich:list>
</rich:column>
</rich:dataTable>
If someone will have the same problem in the future, here is the solution:
The
contentI put intovalueattribute is an object which holds binary data of a image. Because it is serialized in URL, the length is too big and it does not work. You have to pass someidand fetch the object in the paint method.ExampleBEAN