Example usage for org.apache.wicket.request IRequestCycle scheduleRequestHandlerAfterCurrent

List of usage examples for org.apache.wicket.request IRequestCycle scheduleRequestHandlerAfterCurrent

Introduction

In this page you can find the example usage for org.apache.wicket.request IRequestCycle scheduleRequestHandlerAfterCurrent.

Prototype

void scheduleRequestHandlerAfterCurrent(IRequestHandler handler);

Source Link

Document

Schedule the request handler to be executed after the current one.

Usage

From source file:au.org.theark.core.util.ByteDataResourceRequestHandler.java

License:Open Source License

public void respond(IRequestCycle requestCycle) {
    // Write out data as a file in temporary directory
    final String tempDir = System.getProperty("java.io.tmpdir");
    final java.io.File file = new File(tempDir, fileName);

    FileOutputStream fos = null;//from www .  j a v a2  s.  com
    try {
        fos = new FileOutputStream(file);
        fos.write(this.getData(null));
        fos.flush();
    } catch (IOException fe) {
        fe.printStackTrace();
    } finally {
        try {
            if (fos != null) {
                fos.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // Send file back as attachment, and remove after download
    IResourceStream resourceStream = new FileResourceStream(new org.apache.wicket.util.file.File(file));
    requestCycle.scheduleRequestHandlerAfterCurrent(new ResourceStreamRequestHandler(resourceStream) {
        @Override
        public void respond(IRequestCycle requestCycle) {
            super.respond(requestCycle);
            Files.remove(file);
        }
    }.setFileName(fileName).setContentDisposition(ContentDisposition.ATTACHMENT));
}

From source file:gr.abiss.calipso.wicket.components.ByteDataRequestTarget.java

License:Open Source License

public void respond(IRequestCycle requestCycle) {
    ResourceRequestHandler handler = new ResourceRequestHandler(
            new ByteArrayResource(this.mime, this.getData(null), fileName), null);
    requestCycle.scheduleRequestHandlerAfterCurrent(handler);
}