private void addDownloadLinkToItem(ListItem<ViewOutputFormat> item) { DownloadLink downloadLink = new DownloadLink("export-link", new Model<File>() { @Override public File getObject() { return ViewsUtil.exportToTempFile(makeViewGenerator(), (ViewOutputFormatExportable) item.getModelObject()); } }, generateExportFileName(item)); downloadLink.setDeleteAfterDownload(true); downloadLink.setCacheDuration(Duration.NONE); downloadLink.add(new Label("export-label", WordUtils.capitalize(item.getModelObject().getName().toLowerCase()))); item.add(downloadLink); }
/** * * @see org.apache.wicket.markup.html.link.Link#onClick() */ public void onClick() { final File file = (File)getModelObject(); if (file == null) { throw new IllegalStateException(getClass().getName() + " failed to retrieve a File object from model"); } final String fn = (fileName != null) ? fileName : file.getName(); IResourceStream resourceStream = new FileResourceStream( new org.apache.wicket.util.file.File(file)); getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream) { public String getFileName() { return fn; } public void respond(RequestCycle requestCycle) { super.respond(requestCycle); if (deleteAfter) file.delete(); } }); }
@Override protected void onInitialize() { super.onInitialize(); this.add(JQueryWidget.newWidgetBehavior(this)); }
File file = new File(appHome + "/template.xlsx"); add(new DownloadLink("export", file, "template.xlsx"));`
add(new DownloadLink("export", new LoadableDetachableModel<File>() }).setOutputMarkupId(true));
@Override public void onClick() { try { super.onClick(); } catch (IllegalStateException e) { LOG.error("Error: {}", e.getMessage(), e); error("Unable to export curated documents because of exception while processing."); } } }.setDeleteAfterDownload(true)).setOutputMarkupId(true);
add(new DownloadLink("dowloadLog", logFile));
add(new DownloadLink("export", new LoadableDetachableModel<File>() }).setOutputMarkupId(true));
@Override public void onClick() { try { super.onClick(); } catch (IllegalStateException e) { LOG.error("Error: {}", e.getMessage(), e); error("Unable to export curated documents because of exception while processing."); } } }.setDeleteAfterDownload(true)).setOutputMarkupId(true);
public void onClick() final File file = getModelObject(); if (file == null) getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream)
add(new DownloadLink("export", exportFileModel, exportFilenameModel));
@Override protected void onInitialize() { super.onInitialize(); this.add(JQueryWidget.newWidgetBehavior(this)); }
@Override public void onClick() final File file = getModelObject(); if (file == null) getRequestCycle().scheduleRequestHandlerAfterCurrent( new ResourceStreamRequestHandler(resourceStream)
add(new DownloadLink("export", exportFileModel, exportFilenameModel));
@Override protected void onInitialize() { super.onInitialize(); this.add(JQueryWidget.newWidgetBehavior(this)); }
@Override public void onClick() final File file = getModelObject(); if (file == null) getRequestCycle().scheduleRequestHandlerAfterCurrent( new ResourceStreamRequestHandler(resourceStream)