I made a taable with its data source set to BeanItemContainer. Each bean has a name (String) and a byte [], which contains a file converted to byte []. I added a button for each line, which is supposed to load the file, first converting it to pdf. I am having problems implementing the downloadable part, here is the code related:
public Object generateCell(Table source, Object itemId, Object columnId) { // TODO Auto-generated method stub final Beans p = (Beans) itemId; Button l = new Button("Link to pdf"); l.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub try { FileOutputStream out = new FileOutputStream(p.getName() + ".pdf"); out.write(p.getFile()); out.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); l.setStyleName(Reindeer.BUTTON_LINK); return l; } });
So getFile gets byte array from bean
source share