I noted that in Vaadin 7.0.6, sometimes my BrowserFrame contents are blank. In my case, I have the HTML to render (in our case, it’s the HTML content used in an email that was sent out) via a StreamResource that I set as the BrowserFrame.source(). Often, the first time I use it, the content is rendered fine, but when I revisit, the HTML frame is often empty and not showing the content I provided via the StreamResource. In the DOM, it appears as an IFRAME with a link to the get the resource, but somehow that doesn’t always work.
The basic code is:
final byte[] htmlData = EsfString.stringToBytes(html); // basically doing html.getBytes("UTF-8")
StreamResource.StreamSource ss = new StreamResource.StreamSource() {
private static final long serialVersionUID = 8337866232702077402L;
InputStream is = new BufferedInputStream(new ByteArrayInputStream(htmlData));
@Override
public InputStream getStream() {
return is;
}
};
BrowserFrame emailFrame = new BrowserFrame();
emailFrame.setWidth(100,Unit.PERCENTAGE);
emailFrame.setHeight(98,Unit.PERCENTAGE);
emailFrame.setSource(new StreamResource(ss,"email.html"));
panelLayout.addComponent( emailFrame );
Is there something I need to release specially on detach or the like when I’m doing this? In debug, I can see that I am always providing the correct HTML string data, but somehow these dynamic resources are not being returned correctly via the IFRAME src link generated (when I click on the resource URL, it also shows empty in my browser).
When do such dynamic resource URL contents get released? Can I force their release when my window closes that contains my Panel with a BrowserFrame inside? Thanks!