Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9126911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:09:41+00:00 2026-06-17T07:09:41+00:00

So what I have is a DataView with three columns, one of which is

  • 0

So what I have is a DataView with three columns, one of which is a checkbox column that allows users to check which files they would like to download.

For simplicity’s sake (I think); I’ve decided to compress the files into a single zip file and serve it after it’s generated.

Here’s what I have so far:

Code::


    Button downloadLogButton = new Button("downloadlogbutton") {
        private static final long serialVersionUID = 1L;
        @Override
        public void onSubmit() {
            // Some utility class I made that zips files
            LogUtility util = new LogUtility();
            util.zipLogFiles("sample", logs);
        }
    };

    Form logsForm = new Form("logsform") {

    };

    logsForm.add(downloadLogButton);

    CheckGroup<File> checkGroup = new CheckGroup<File>("logscheckgroup", new ArrayList<File>());
    WebMarkupContainer logsViewContainer = new WebMarkupContainer("datatable");
    DataView<File> logsView = new DataView<File>("logrows", new ListDataProvider<File>(logs)) {

        private static final long serialVersionUID = 1L;

        public void populateItem(final Item<File> item) {
            final File file = (File) item.getModelObject();
            item.add(new Check<File>("logdownloadcheck", item.getModel()));
            item.add(new Label("logname", file.getName()));
            SimpleDateFormat sdf = new SimpleDateFormat( "E, dd MMM yyyy  hh:mm a");
            item.add(new Label("logdatemodified", sdf.format(file .lastModified())));
        }
    };

    logsViewContainer.add(logsView);
    checkGroup.add(logsViewContainer);
    logsForm.add(checkGroup);
    add(logsForm);

How do I serve the zip file after it is generated for download? What are my options? I’d like to avoid having to redirect them to a confirmation page or a Your download is ready page.

UPDATE

Based on Xavi López answer, I added the following code in my Button‘s onSubmit function.

org.apache.wicket.util.file.File log = new org.apache.wicket.util.file.File("/home/keeboi/Downloads/sample.zip");

IResourceStream resourceStream = new FileResourceStream(log);
IRequestHandler target = new ResourceStreamRequestHandler(resourceStream);

getRequestCycle().scheduleRequestHandlerAfterCurrent(target);

And I’m getting HTTP Error 404: Not Found.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:09:42+00:00Added an answer on June 17, 2026 at 7:09 am

    You could do just like DownloadLink does and create a FileResourceStream from the zipped file. Then, just change the target of the current request cycle:

    Button downloadLogButton = new Button("downloadlogbutton") {
        private static final long serialVersionUID = 1L;
        @Override
        public void onSubmit() {
            // Some utility class I made that zips files
            LogUtility util = new LogUtility();
            util.zipLogFiles("sample", logs);
            IResourceStream resourceStream = new FileResourceStream(
                new org.apache.wicket.util.file.File(someFile)); // Use whatever file you need here
            IRequestTarget t = new ResourceStreamRequestTarget(stream){
                @Override
                public String getFileName() {
                    return "filename.zip";
                }
            }
            getRequestCycle().setRequestTarget(t);
        }
    };
    

    If you wanted to delete the file after the download, you could override IRequestTarget#respond(RequestCycle) like this:

    @Override
    public void respond(RequestCycle requestCycle) {
        super.respond(requestCycle);
        // Delete the file
        ((FileResourceStream)getResourceStream()).getFile().delete();
    }
    

    The following related question could also be useful: How to use Wicket’s DownloadLink with a file generated on the fly?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView which is bound to a DataTable that contains a column
I have a method in my web service which returns a DataView, I have
How to filter DataView/DataTable by time? I have a table with datetime column inside
Have deployed numerous report parts which reference the same view however one of them
I have a DataView that is always displaying the scroller, I need the scroller
Alright i have a table which contains 2 bigint column. Example val1 3213 12312
I have a requirement to sort the values of a data table column. That
I have a dataview with the following columns: <Columns> <asp:BoundField DataField=report_type HeaderText=Report Type ReadOnly=True
In Sencha Touch, I often need to have an Ext.DataView panel that contains a
I would like to fill in my DataGridView with a DataView that we can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.