当前位置: 首页>>代码示例>>Java>>正文


Java ResourceStreamRequestHandler类代码示例

本文整理汇总了Java中org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler的典型用法代码示例。如果您正苦于以下问题:Java ResourceStreamRequestHandler类的具体用法?Java ResourceStreamRequestHandler怎么用?Java ResourceStreamRequestHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceStreamRequestHandler类属于org.apache.wicket.request.handler.resource包,在下文中一共展示了ResourceStreamRequestHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
public void onRequest() {
	final File file = initFile();	
	IResourceStream resourceStream = new FileResourceStream(new File(file));
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
			new ResourceStreamRequestHandler(resourceStream) {

                   @Override
				public void respond(IRequestCycle requestCycle) {
                       try {
					    super.respond(requestCycle);
                       } finally {
                           if (removeFile) {
                               LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
                               Files.remove(file);
                           }
                       }
				}
			}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
					.setCacheDuration(Duration.ONE_SECOND));
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:AjaxDownloadBehaviorFromFile.java

示例2: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
public void onRequest() {
	
	IResourceStream resourceStream = getResourceStream();
	if (resourceStream == null) {
		return;		// We hope the error was already processed and will be shown.
	}

       ResourceStreamRequestHandler reqHandler = new ResourceStreamRequestHandler(resourceStream) {
           @Override
           public void respond(IRequestCycle requestCycle) {
               super.respond(requestCycle);
           }
       }.setContentDisposition(ContentDisposition.ATTACHMENT)
               .setCacheDuration(Duration.ONE_SECOND);
       if (StringUtils.isNotEmpty(getFileName())){
           reqHandler.setFileName(getFileName());
       }
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(reqHandler);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:AbstractAjaxDownloadBehavior.java

示例3: createExportButton

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
private void createExportButton(boolean visible) {
    exportLink = new Link("export") {
        @Override
        public void onClick() {

            JsonNode doc = documentService.getDocumentById(docId);
            String filename = doc.get("data").get("Title").asText() + ".pdf";
            final ByteArrayOutputStream baos = documentService.convertToPdf(doc);
            AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() {

                @Override
                public void write(OutputStream output) throws IOException {
                    output.write(baos.toByteArray());
                    baos.close();
                    output.close();
                }
            };

            ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(rstream, filename);        
            getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
        }
    };
    addComponent(exportLink, visible);
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:25,代码来源:DocumentWorkflow.java

示例4: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
public void onRequest() {
	final File file = initFile();
	IResourceStream resourceStream = new FileResourceStream(new File(file));
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
			new ResourceStreamRequestHandler(resourceStream) {

                   @Override
				public void respond(IRequestCycle requestCycle) {
                       try {
					    super.respond(requestCycle);
                       } finally {
                           if (removeFile) {
                               LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
                               Files.remove(file);
                           }
                       }
				}
			}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
					.setCacheDuration(Duration.ONE_SECOND));
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:21,代码来源:AjaxDownloadBehaviorFromFile.java

示例5: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
public void onRequest() {

		IResourceStream resourceStream = getResourceStream();
		if (resourceStream == null) {
			return;		// We hope the error was already processed and will be shown.
		}

        ResourceStreamRequestHandler reqHandler = new ResourceStreamRequestHandler(resourceStream) {
            @Override
            public void respond(IRequestCycle requestCycle) {
                super.respond(requestCycle);
            }
        }.setContentDisposition(ContentDisposition.ATTACHMENT)
                .setCacheDuration(Duration.ONE_SECOND);
        if (StringUtils.isNotEmpty(getFileName())){
            reqHandler.setFileName(getFileName());
        }
		getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(reqHandler);
	}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:20,代码来源:AbstractAjaxDownloadBehavior.java

示例6: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onRequest() {
    HttpResourceStream stream = getResourceStream();
    ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(stream);
    String key = StringUtils.isNotBlank(fileKey) ? fileKey + "_" : "";
    String ext = "";
    if (StringUtils.isNotBlank(mimeType)) {
        String extByMimeType = MIME_TYPES_LOADER.getFileExt(mimeType);
        ext = StringUtils.isBlank(extByMimeType) ? ".bin" : ("." + extByMimeType);
    }
    String fileName = key + (stream.getFilename() == null ? name : stream.getFilename()) + ext;

    handler.setFileName(fileName);
    handler.setContentDisposition(ContentDisposition.ATTACHMENT);
    getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
 
开发者ID:apache,项目名称:syncope,代码行数:17,代码来源:AjaxDownload.java

示例7: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onRequest() {

    IResourceStream resourceStream = new AbstractResourceStreamWriter() {
        @Override
        public String getContentType() {
            return exportAction.getContentType();
        }
        @Override
        public void write(OutputStream output) throws IOException {
            exportAction.writeContent(output);
        }

    };

    RequestCycle.get().scheduleRequestHandlerAfterCurrent(new ResourceStreamRequestHandler(resourceStream, exportAction.getFileName()));

}
 
开发者ID:jkrasnay,项目名称:panelized,代码行数:19,代码来源:ExportBehavior.java

示例8: onClick

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onClick() {
	final InputStream stream = getModelObject();
	if (stream == null) {
		throw new IllegalStateException(getClass().getName() + " failed to retrieve a File object from model");
	}

	InputStreamResourceStream resourceStream = new InputStreamResourceStream(stream);
	// maybe file name and display name should be seperated?
	ResourceStreamRequestHandler requestHandler = new ResourceStreamRequestHandler(resourceStream,
			String.valueOf(getBody().getObject()));
	requestHandler.setContentDisposition(ContentDisposition.ATTACHMENT);
	getRequestCycle().scheduleRequestHandlerAfterCurrent(requestHandler);
}
 
开发者ID:pingunaut,项目名称:wicket-stream-download-example,代码行数:15,代码来源:InputStreamDownloadLink.java

示例9: mapRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public IRequestHandler mapRequest(Request request) {
	final Url url = new Url(request.getUrl());
	
	if (!urlStartsWith(url, mountSegments)) {
		return null;
	}
	
	url.removeLeadingSegments(mountSegments.length);
	
	return new ResourceStreamRequestHandler(new PackageResourceStream(scope, url.getPath()));
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:13,代码来源:StaticResourceMapper.java

示例10: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onRequest() {
    final ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(getResourceStream(),
            getFileName());
    handler.setContentDisposition(ContentDisposition.ATTACHMENT);
    getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:8,代码来源:AAjaxDownload.java

示例11: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onRequest()
{
    ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(
            getResourceStream(), getFileName());
    handler.setContentDisposition(ContentDisposition.ATTACHMENT);
    getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:9,代码来源:AJAXDownload.java

示例12: commonInit

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
void commonInit()
{
    downloadBehavior = new AbstractAjaxBehavior()
    {
        private static final long serialVersionUID = 3472918725573624819L;

        @Override
        public void onRequest()
        {
            String name = filename != null ? filename.getObject() : null;
            
            // If no filename has been set explicitly, try to get it from the resource
            IResourceStream is = AjaxDownloadLink.this.getModelObject();
            if (name == null) {
                if (is instanceof FileResourceStream) {
                    name = ((FileResourceStream) is).getFile().getName();
                }
                else if (is instanceof FileSystemResourceStream) {
                    name = ((FileSystemResourceStream) is).getPath().getFileName().toString();
                }
            }
            
            ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(
                    AjaxDownloadLink.this.getModelObject(), name);
            handler.setContentDisposition(ContentDisposition.ATTACHMENT);
            getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
        }
    };
    add(downloadBehavior);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:31,代码来源:AjaxDownloadLink.java

示例13: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onRequest() {
    RequestCycle.get().scheduleRequestHandlerAfterCurrent(
            new ResourceStreamRequestHandler(getResourceStream())
                    .setFileName(fileName)
                    .setContentDisposition(ContentDisposition.ATTACHMENT));
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:8,代码来源:AjaxSettingsDownloadBehavior.java

示例14: onClick

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onClick() {
    IResourceStream resourceStream = getResourceStream();
    RequestCycle requestCycle = getRequestCycle();
    WebResponse response = (WebResponse) requestCycle.getResponse();
    response.setHeader("Cache-Control", "no-store");

    requestCycle.scheduleRequestHandlerAfterCurrent(
            new ResourceStreamRequestHandler(resourceStream)
                    .setFileName(getFileName())
                    .setContentDisposition(ContentDisposition.ATTACHMENT));
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:13,代码来源:DownloadButton.java

示例15: onRequest

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; //导入依赖的package包/类
@Override
public void onRequest() {
    try {
        getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
                new ResourceStreamRequestHandler(getResourceStream(), getFileName()));
    } catch (Exception e) {
        // cannot be notifies beacause the use of scheduleRequestHandlerAfterCurrent
        LOG.error("Error downloading file", e);
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:11,代码来源:AbstractAjaxDownloadBehavior.java


注:本文中的org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。