commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "simon.kitching@chello.at" <simon.kitch...@chello.at>
Subject Re: [fileupload] unable to find setProgress method
Date Thu, 03 Jul 2008 08:11:19 GMT
Thomas Favre-Bulle schrieb:
>
>
> simon.kitching@chello.at a écrit :
>> Thomas Favre-Bulle schrieb:
>>> Hi everyone !
>>>
>>> I'm using fileupload lib in order to implement an upload progress bar.
>>> Unfortunately, it seems there's a problem with 
>>> org.apache.commons.fileupload.servlet.ServletFileUpload, each time I 
>>> try to compile I get the following error :
>>>
>>> symbol  : method 
>>> setProgressListener(infoserver.control.FileUploadListener)
>>> location: class org.apache.commons.fileupload.servlet.ServletFileUpload
>>>        upload.setProgressListener(listener);
>>> 1 error
>>>
>>>
>>> Here is the code :
>>>
>>> FileItemFactory factory = new DiskFileItemFactory();
>>> ServletFileUpload upload = new ServletFileUpload(factory);
>>>
>>> // set file upload progress listener
>>> FileUploadListener listener = new FileUploadListener();
>>> HttpSession session = request.getSession();
>>>
>>> session.setAttribute("LISTENER", listener);
>>>       // upload servlet allows to set upload listener
>>> upload.setProgressListener(listener);
>>>
>>>
>>> I'm using version 1.2.1 and JDK 1.6.
>>>
>>> Any idea ?
>> Does your infoserver.control.FileUploadListener class implement the 
>> org.apache.commons.fileupload.ProgressListener interface?
>>
>> Regards,
>> Simon
>>
> Yes it does :
>
> public class FileUploadListener implements ProgressListener {
>
>    private volatile long bytesRead = 0L,  contentLength = 0L,  item = 0L;
>
>    public FileUploadListener() {
>        super();
>    }
>
>    public void update(long aBytesRead, long aContentLength, int anItem) {
>        bytesRead = aBytesRead;
>        contentLength = aContentLength;
>        item = anItem;
>    }
>
>    public long getBytesRead() {
>        return bytesRead;
>    }
>
>    public long getContentLength() {
>        return contentLength;
>    }
>
>    public long getItem() {
>        return item;
>    }
>
>
>
> I forgot to add commons.io dependecy but adding it did not solve the 
> problem.
Then I have no idea what your problem is. I checked the jarfile and it 
looks ok:
  javap -classpath commons-fileupload-1.2.1.jar 
org.apache.commons.fileupload.FileUploadBase
reports
    public void 
setProgressListener(org.apache.commons.fileupload.ProgressListener);
is present.

You could perhaps try
   upload.setProgressListener(
     (org.apache.commons.fileupload.ProgressListener) listener);
just as a test.

Regards, Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message