This is a follow up of How to upload an image using ByteArrayOutputStream in Vaadin?
I put the code from there into my app. However, the inner part of the overridden getStream() is called only once and on the next image change attempt, no more. The code outside is executed. No statics used.
final byte [] imageBytes = beanItem.getPicture(); // a byte []
StreamSource streamSource = new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
System.out.println(">>>> streamResource:getStream called.size:" + imageBytes.length);
return (imageBytes == null) ? null : new ByteArrayInputStream(imageBytes);
}
};
StreamResource imageResource = new StreamResource(streamSource, "");
image.setSource (imageResource);
Any help is appreciated.
Regards Gerry