Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3526

Augment JakartaMultiPartRequest to include optional progress listener

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 6.1.1
    • 6.5.0
    • Dispatch Filter
    • None
    • N/A

    Description

      Original concept from David Casserly: see http://www.devedup.com/ajaxfileupload/

      The basic idea is to augment JakartaMultiPartRequest to allow users to specify a file upload progress listener (see Commons FileUpload ServletFileUpload.setProgressListener()). The original concept by Casserly references a specific ProgressMonitor class that implements FileUpload's ProgressListener interface. I'd propose an alternate solution: allow the user to configure the fully-qualified name of an optional listener class via @Inject("struts.multipart.monitor"), then:

      o require the listener class to also implement an interface that specifies public void abort(); as its only method;
      o in JakartaMultiPartRequest.parseRequest(), attempting to instantiate the specified listener class via Class.forName().newInstance();
      o store the instantiated listener in the session, as per Casserly's example;
      o in JakartaMultiPartRequest.parse(), in the catch(FileUploadException) block, calling the abort() method on the listener class if it is in the session.

      Users can then implement an action that retrieves the upload status (via AJAX or some other mechanism) by retrieving their listener object from the session (as per Casserly's example.) AJAX retrieval allows implementation of file upload progress bars, a la GMail's attachment upload mechanism.

      One possible issue I see with this is: what happens if multiple file upload requests happen simultaneously for a user session?

      I have a partial implementation but I'm not familiar with the Struts development process or philosophies, so I'm throwing this out there for review. If there are better ways to do this, let me know. I can (eventually) provide a patch to 2.2.1 or HEAD with a little assistance, I think.

      Attachments

        1. upload-listener.tar.gz
          3 kB
          Bob Glamm

        Activity

          People

            Unassigned Unassigned
            bob.glamm Bob Glamm
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: