Example usage for org.apache.wicket.request.resource ResourceStreamResource setCacheDuration

List of usage examples for org.apache.wicket.request.resource ResourceStreamResource setCacheDuration

Introduction

In this page you can find the example usage for org.apache.wicket.request.resource ResourceStreamResource setCacheDuration.

Prototype

public ResourceStreamResource setCacheDuration(Duration cacheDuration) 

Source Link

Usage

From source file:org.dcache.webadmin.view.panels.billingplots.PlotsPanel.java

License:Open Source License

/**
 * Two thirds of this method is shared with {@link ThumbnailPanelBean};
 * the latter needs to be generalized to cover this case. TODO
 *///w w w  .  ja  v a  2s .  c o m
private void loadPlots(File[] files, int width, int height) {
    int n = 0;
    int m = 0;
    for (File file : files) {
        String suffix = "_" + m + n;
        ResourceStreamResource resource = new ResourceStreamResource(new FileResourceStream(file));
        resource.setCacheDuration(Duration.NONE);
        Image image = new Image(IMAGE_NAME + suffix, resource);
        PopupSettings popupSettings = new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS)
                .setHeight(height).setWidth(width);
        ResourceLink link = new ResourceLink(LINK_NAME + suffix, resource);
        link.setPopupSettings(popupSettings);
        link.add(image);
        add(link);
        n = (n + 1) % 4;
        if (n == 0) {
            ++m;
        }
    }
}

From source file:org.hippoecm.frontend.plugins.console.editor.BinaryEditor.java

License:Apache License

public BinaryEditor(String id, JcrPropertyModel model, final IPluginContext pluginContext) {
    super(id, model);
    final IResourceStream stream = new BinaryResourceStream(model);

    // download/*ww  w.j  av  a2  s  .c o m*/
    final ResourceStreamResource resource = new ResourceStreamResource(stream);
    resource.setCacheDuration(Duration.NONE);
    try {
        final Node node = model.getProperty().getParent().getParent();
        final StringBuilder fileName = new StringBuilder(node.getName());
        if (isExtractedTextProperty(model.getProperty())) {
            fileName.append(".txt");
        }
        resource.setFileName(fileName.toString());
    } catch (RepositoryException e) {
        log.error("Unexpected exception while determining download filename", e);
    }
    final Link downloadLink = new ResourceLink("binary-download-lnk", resource);
    downloadLink.add(new Label("binary-download-text", "download (" + getSizeString(stream.length()) + ")"));
    add(downloadLink);

    // upload
    IDialogFactory factory = new IDialogFactory() {
        private static final long serialVersionUID = 1L;

        public IDialogService.Dialog createDialog() {
            return new BinaryUploadDialog(model);
        }
    };
    final IDialogService service = pluginContext.getService(IDialogService.class.getName(),
            IDialogService.class);
    final DialogLink uploadLink = new DialogLink("binary-upload-link", new Model<>("Upload binary"), factory,
            service);
    add(uploadLink);

    // Jackrabbit Binary Content Identifier if this Binary is in BinaryStore.
    final Label contentIdentityValueLabel = new Label("content-identity-value",
            new PropertyModel<String>(this, "contentIdentity"));
    contentIdentityValueLabel.setOutputMarkupPlaceholderTag(true);
    contentIdentityValueLabel.setVisible(false);
    add(contentIdentityValueLabel);
    final AjaxLink contentIdentityShowLink = new AjaxLink("content-identity-show-link") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            setContentIdentity(retrieveJackrabbitContentIdentity());
            target.add(contentIdentityValueLabel.setVisible(true));
            target.add(this.setVisible(false));
        }
    };
    add(contentIdentityShowLink);
}