@Override protected void populateItem(ListItem<URI> item) { ResourceStreamResource lopZipStream = makeZipLogStream(item.getModel()); lopZipStream.setFileName("log.zip"); ResourceLink downloadLink = new ResourceLink("log", lopZipStream); downloadLink.add(new Label("label", Paths.get(item.getModelObject()).getFileName().toString())); item.add(downloadLink); } });
/** * @see org.apache.wicket.markup.html.link.Link#getURL() */ protected final CharSequence getURL() { if (resourceReference != null) { // TODO post 1.2: should we have support for locale changes when the // resource reference (or resource??) is set manually.. // We should get a new resource reference for the current locale // then // that points to the same resource but with another locale if it // exists. // something like // SharedResource.getResourceReferenceForLocale(resourceReference); resourceReference.bind(getApplication()); return getRequestCycle().urlFor(resourceReference, resourceParameters); } return urlFor(IResourceListener.INTERFACE); } }
@Override protected void onInitialize() { super.onInitialize(); this.add(JQueryWidget.newWidgetBehavior(this)); }
protected void initialize() { add((dataLink = new ResourceLink<byte[]>("data", new AbstractResource() { @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType("application/octet-stream"); String filename = nameModel.getObject(); resourceResponse.setFileName(filename); resourceResponse.setWriteCallback(new WriteCallback() { @Override public void writeData(Attributes attributes) throws IOException { byte[] data = (byte[])BinaryViewPanel.this.getModelObject(); if(data!=null) { OutputStream outputStream = attributes.getResponse().getOutputStream(); outputStream.write((byte[])BinaryViewPanel.this.getModelObject()); } } }); return resourceResponse; } })).setBody(nameModel)); }
@Override protected AbstractLink newLink(String id) { return new ResourceLink<Object>(id, new DatabaseExportResource() { @Override protected ResourceResponse newResourceResponse(Attributes attrs) { ResourceResponse resourceResponse = super.newResourceResponse(attrs); resourceResponse.setFileName("schema.gz"); return resourceResponse; } @Override protected void configureODatabaseExport(ODatabaseExport dbExport) { dbExport.setOptions("-excludeAll=true -includeSchema=true"); } }); }
.getGuideline(aModel.getObject().getProject(), guidelineFileName)); ResourceStreamResource resource = new ResourceStreamResource(stream); ResourceLink<Void> rlink = new ResourceLink<>("guideine", resource); rlink.setPopupSettings(popupSettings); item.add(new Label("guidelineName", guidelineFileName)); item.add(rlink);
@Override protected final CharSequence getURL() { if (resourceReference != null) { // TODO post 1.2: should we have support for locale changes when the // resource reference (or resource??) is set manually.. // We should get a new resource reference for the current locale // then // that points to the same resource but with another locale if it // exists. // something like // SharedResource.getResourceReferenceForLocale(resourceReference); if (resourceReference.canBeRegistered()) { getApplication().getResourceReferenceRegistry().registerResourceReference( resourceReference); } return getRequestCycle().urlFor( new ResourceReferenceRequestHandler(resourceReference, resourceParameters)); } return urlForListener(resourceParameters); }
@Override protected AbstractLink newLink(String id) { return new ResourceLink<>(id, new AbstractResource() { @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType("text/xml"); resourceResponse.setFileName((String)BpmnPanel.this.getModelObject().field("name")); resourceResponse.setWriteCallback(new WriteCallback() { @Override public void writeData(Attributes attributes) throws IOException { OutputStream out = attributes.getResponse().getOutputStream(); out.write((byte[])BpmnPanel.this.getModelObject().field("bytes")); } }); return resourceResponse; } }); }
/** * Creates a new link to the exported data for the provided {@link IDataExporter}. * * @param componentId * The component of the link. * @param dataExporter * The data exporter to use to export the data. * @return a new link to the exported data for the provided {@link IDataExporter}. */ protected Component createExportLink(String componentId, final IDataExporter dataExporter) { IResource resource = new ResourceStreamResource() { @Override protected IResourceStream getResourceStream(Attributes attributes) { return new DataExportResourceStreamWriter(dataExporter, getTable()); } }.setFileName(fileNameModel.getObject() + "." + dataExporter.getFileNameExtension()); return new ResourceLink<Void>(componentId, resource) .setBody(dataExporter.getDataFormatNameModel()); }
@Override protected final CharSequence getURL() { if (resourceReference != null) { // TODO post 1.2: should we have support for locale changes when the // resource reference (or resource??) is set manually.. // We should get a new resource reference for the current locale // then // that points to the same resource but with another locale if it // exists. // something like // SharedResource.getResourceReferenceForLocale(resourceReference); if (resourceReference.canBeRegistered()) { getApplication().getResourceReferenceRegistry().registerResourceReference( resourceReference); } return getRequestCycle().urlFor( new ResourceReferenceRequestHandler(resourceReference, resourceParameters)); } return urlForListener(resourceParameters); }
@Override protected void populateItem(ListItem<URI> item) { ResourceStreamResource lopZipStream = makeZipLogStream(item.getModel()); lopZipStream.setFileName("log.zip"); ResourceLink downloadLink = new ResourceLink("log", lopZipStream); downloadLink.add(new Label("label", Paths.get(item.getModelObject()).getFileName().toString())); item.add(downloadLink); } });
@Override protected AbstractLink newLink(String id) { IResource resource = new ResourceStreamResource() { @Override protected IResourceStream getResourceStream(Attributes attrs) { return new DataExportResourceStreamWriter(dataExporter, table); } }.setFileName(fileNameModel.getObject() + "." + dataExporter.getFileNameExtension()); return new ResourceLink<Void>(id, resource); }
/** * @see org.apache.wicket.markup.html.link.Link#getURL() */ @Override protected final CharSequence getURL() { if (resourceReference != null) { // TODO post 1.2: should we have support for locale changes when the // resource reference (or resource??) is set manually.. // We should get a new resource reference for the current locale // then // that points to the same resource but with another locale if it // exists. // something like // SharedResource.getResourceReferenceForLocale(resourceReference); resourceReference.bind(getApplication()); return getRequestCycle().urlFor(resourceReference, resourceParameters); } return urlFor(IResourceListener.INTERFACE); } }
@Override protected void onInitialize() { super.onInitialize(); this.add(JQueryWidget.newWidgetBehavior(this)); }
@Override protected void populateItem(ListItem<URI> item) { ResourceStreamResource lopZipStream = makeZipLogStream(item.getModel()); lopZipStream.setFileName("log.zip"); ResourceLink<?> downloadLink = new ResourceLink<>("log", lopZipStream); downloadLink.add(new Label("label", Paths.get(item.getModelObject()).getFileName().toString())); item.add(downloadLink); } });
@Override protected void onInitialize() { super.onInitialize(); add(new ResourceLink<Void>("download", new ServerLogResourceReference())); List<String> lines = ServerLogResource.readServerLog(); String content; if (lines.size() > MAX_DISPLAY_LINES) { add(new Label("warning", "Too many log entries, displaying recent " + MAX_DISPLAY_LINES)); content = Joiner.on("\n").join(lines.subList(lines.size()-MAX_DISPLAY_LINES, lines.size())); } else { add(new WebMarkupContainer("warning").setVisible(false)); content = Joiner.on("\n").join(lines); } add(new Label("logContent", content)); }
@Override protected void onInitialize() { super.onInitialize(); this.add(JQueryWidget.newWidgetBehavior(this)); }
ResourceEditor(String id, JcrNodeModel nodeModel) { super(id); JcrResourceStream stream = new JcrResourceStream(nodeModel); ResourceLink link = new ResourceLink("resource-link", new JcrResource(stream)); add(link); String size; long length = stream.length(); if (length / ONE_GB > 0) { size = String.valueOf(length / ONE_GB) + " GB"; } else if (length / ONE_MB > 0) { size = String.valueOf(length / ONE_MB) + " MB"; } else if (length / ONE_KB > 0) { size = String.valueOf(length / ONE_KB) + " KB"; } else { size = String.valueOf(length) + " bytes"; } link.add(new Label("resource-link-text", "download (" + size + ")")); }
public BirtManagementPanel(String id,final AbstractBirtReportPanel reportPanel) { super(id); final AjaxPagingNavigator pager = new AjaxPagingNavigator(PAGER_NAME, reportPanel) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(reportPanel); target.add(this); } }; add(pager); add(new ResourceLink<>("HTML", new HtmlBirtResource(reportPanel))); add(new ResourceLink<>("PDF", new PDFBirtResource(reportPanel))); add(new ResourceLink<>("Excel", new ExcelBirtResource(reportPanel))); add(new ParamsListView("params",reportPanel.getParametersDefenitions(),reportPanel,pager)); add(new ParamsListView("hiddenParams",reportPanel.getHiddenParametersDefinitions(),reportPanel,pager)); } ////////////////////////////////////////////////////////////////////////
export.setCacheable(false); ResourceLink<Object> resourceLink = new ResourceLink<Object>("export", export); resourceLink.add(new SimpleAttributeModifier("value", new ResourceModel("AdminPage.export.button").getObject().toString())); form.add(resourceLink);