I’m trying to implement a download functionality using a button renderer within a Grid, but I don’t know how to make it work. Here is a part of my code:
@Override
public void click(RendererClickEvent event)
{
final javax.xml.transform.stream.StreamSource source = new javax.xml.transform.stream.StreamSource(image_byte);
final StreamSource streamSource = new StreamSource()
{ @Override
public InputStream getStream()
{
return source.getInputStream();
}
};
StreamResource streamResource = new StreamResource(streamSource, nome_arquivo);
FileDownloader fileDownloader = new FileDownloader(streamResource);
fileDownloader.extend(event…);
}
I played around this subject a bit last spring and came up with
GridFileDownloader add-on , but it’s not exactly perfect and I haven’t had time to work on it since. You might find some inspiration from the sources, though.