When activeReverseAjaxEnabled is true, File upload progress call not working

View: New views
6 Messages — Rating Filter:   Alert me  

When activeReverseAjaxEnabled is true, File upload progress call not working

by ddduuu () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, all,

I have a fileupload webapp with a progress bar,  I upload a file through Ext ajax call to a servlet, which transfers a file with commons-fileupload library, I have a timer-triggered (every one second) dwr call to retrieve the upload status from server side with a callback function to update the progress bar, it works great when I set activeReverseAjaxEnabled to false, but when I set it to true, the dwr call will always come back to call the callback javascript function after the servlet returns and upload is already done at that point, so the progress bar does not show any progress at all.

I am not sure why the ReverseAjax prevented my dwr function from being called immediately. I checked my log file, the DWR call getUploadInfo() is called after the servlet is returned all the time. but if I set the activeReverseAjaxEnabled to false, the DWR call getUploadInfo() will be called before servlet doPost is done.

I tried ScriptProxy.addFunctionCall() instead of a callback function, it showed the same problem.
By the way, I am using DWR2.0.1, I tried DWR2.0.2 and 2.0.3, they have the same problem, also they have other problems such as a long waitAfterWrite time even though I set maxWaitAfterWrite to 500.

Anybody has any clue about this issue?


Thanks in advance.

Dave

Re: When activeReverseAjaxEnabled is true, long time delay for java call

by XMaNIaC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I would just use DWR FileTransfer and the progress bars it provides. Take a look at IWebMvc if you need some help.

Regards,

On Fri, Apr 18, 2008 at 9:37 PM, ddduuu <davidkdu@...> wrote:

Hi, all,

I have fileupload webapp with progress bar,  I upload the file through Ext
ajax call to a servlet, which transfers file with commons-fileupload
library, I have a dwr call to retrieve the upload status from server side
with a callback function to update the progress bar, it works great when I
set activeReverseAjaxEnabled to false, but when I set it to true, the dwr
call will always come back to call the callback javascript function after
the servlet returns and upload is already done at that point, so the
progress bar does not show any progress at all.

I am not sure why the ReverseAjax prevented my dwr function from being
called immediately. I checked my log file, the DWR call getUploadInfo() is
called after the servlet is returned all the time. but if I set the
activeReverseAjaxEnabled to false, the DWR call getUploadInfo() will be
called before servlet doPost is done.

Anybody has any clue about this issue?

Thanks in advance.

Dave
--
View this message in context: http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16764605.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: When activeReverseAjaxEnabled is true, long time delay for java call

by ddduuu () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, XmaNIaC and all,

Thanks for your help, I just upgraded my webapp dwr.jar library file from version 2.0.1 to 3.0M1, I have three questions:
1). I am using Firefox and tomcat 6.0.16, when I open two separate Firefox windows on the same machine and point both url to connect to my web app, the Reverse Ajax calls are very slow, it takes about 50 seconds to get response, but when they are opened from different machines, then it works fine, when I used version 2.0.1, there was no such a problem. what do I need to do to fix that? my web.xml setting:

<init-param>
              <param-name>activeReverseAjaxEnabled</param-name>
              <param-value>true</param-value>
            </init-param>
            <init-param>
            <!--full streaming mode with -1, early closing mode with 500</description>-->
              <param-name>maxWaitAfterWrite</param-name>
              <param-value>500</param-value>
            </init-param>

2). I looked into the FileTransfer feature, but could not figure out if it will work for any files or just image files?

3). I implemented ScriptSessionListener and bind it to ScriptSession from setAttribute, but the sessionCreated(ScriptSessionEvent event) method and sessionDestroyed(ScriptSessionEvent event) are nevered called, not sure if I need to do some configuration in web.xml, since I am thinking dwr will use the DefaultScriptSessionManager, I donot need to configure it.

Thanks in advance for your help.

Dave

XMaNIaC wrote:
Hi

I would just use DWR FileTransfer and the progress bars it provides. Take a
look at IWebMvc if you need some help.

Regards,

On Fri, Apr 18, 2008 at 9:37 PM, ddduuu <davidkdu@gmail.com> wrote:

>
> Hi, all,
>
> I have fileupload webapp with progress bar,  I upload the file through Ext
> ajax call to a servlet, which transfers file with commons-fileupload
> library, I have a dwr call to retrieve the upload status from server side
> with a callback function to update the progress bar, it works great when I
> set activeReverseAjaxEnabled to false, but when I set it to true, the dwr
> call will always come back to call the callback javascript function after
> the servlet returns and upload is already done at that point, so the
> progress bar does not show any progress at all.
>
> I am not sure why the ReverseAjax prevented my dwr function from being
> called immediately. I checked my log file, the DWR call getUploadInfo() is
> called after the servlet is returned all the time. but if I set the
> activeReverseAjaxEnabled to false, the DWR call getUploadInfo() will be
> called before servlet doPost is done.
>
> Anybody has any clue about this issue?
>
> Thanks in advance.
>
> Dave
> --
> View this message in context:
> http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16764605.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
> For additional commands, e-mail: users-help@dwr.dev.java.net
>
>

Re: When activeReverseAjaxEnabled is true, File upload progress call not working

by ddduuu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, XMaNIaC and all,

I am now using the DWR FileTransfer with the help of IWebMvc example to upload files, but unfortunately, the problem is the same, when I set activeReverseAjaxEnabled to true in web.xml, the getStatus() call will be called after all the bytes of the file are transferred, so the progress bar will not show the progress of the uploading process and only show 100% in the end of the transferring process, and the file is transferred successfully since I can see the file in the folder I configured.

also one more problem is that the file transfer will failed when the file is too big like over 16MB.

The strange thing is that If I switch activeReverseAjaxEnabled to false, then the progress bar can show the progress smoothly. I check my log file, it shows getStatus() calls between the calls to update(long newBytesRead, long newContentLength, int items) of SessionProgressListener (I added logging messages in this method), but with activeReverseAjaxEnabled set to true, the log file shows the getStatus() call is always in the end of the file transferring and the all update() calls are already done with all bytes read.

I think in the IWebMvc example, the problem exists as well, it is just a small image file uploading finishes very fast, it is not easy to notice, but with a bigger file, it should show the progress on the progress bar.

Here is the code block:
 uploadFile : function(record)
  {
 
      var  uploadFinished = function(status){
                        var data = {
                      record: record,
                      response: status
                    }
                    if (status.success) {
                      this.fsa.postEvent('file-upload-success', data);
                    }
                    else {
                      this.fsa.postEvent('file-upload-error', data);
                    }
      }
      UploadMonitor.upload(this.inputUploadFile, uploadFinished.createDelegate(this));
       window.setTimeout("checkStatus()", 500);

  }

function checkStatus() {
    UploadMonitor.getStatus(updateProgress);
}

function updateProgress(data) {
        if(data){
                var percentage = (100 * data.bytesRead / data.contentLength)|0;//can use parseInt(b/c)
                var progressbar = Ext.getCmp('uploadprogressid');
                progressbar.updateProgress(i,'Upload in progress: ' + percentage + '%');
                if (percentage < 100)
                window.setTimeout(checkStatus, 100);
       }else window.setTimeout(checkStatus, 100);
 
}

Thans very much and please help me solve the problem.
By the way, I tested on DWR3.0M1, DWR2.0.3, 2.0.4, DWR3.0build 103. they all have this problem. I am using Tomcat 6.0.16. and tried both JDK1.5 and JDK1.6.

Dave

XMaNIaC wrote:
Hi

I would just use DWR FileTransfer and the progress bars it provides. Take a
look at IWebMvc if you need some help.

Regards,

On Fri, Apr 18, 2008 at 9:37 PM, ddduuu <davidkdu@gmail.com> wrote:

>
> Hi, all,
>
> I have fileupload webapp with progress bar,  I upload the file through Ext
> ajax call to a servlet, which transfers file with commons-fileupload
> library, I have a dwr call to retrieve the upload status from server side
> with a callback function to update the progress bar, it works great when I
> set activeReverseAjaxEnabled to false, but when I set it to true, the dwr
> call will always come back to call the callback javascript function after
> the servlet returns and upload is already done at that point, so the
> progress bar does not show any progress at all.
>
> I am not sure why the ReverseAjax prevented my dwr function from being
> called immediately. I checked my log file, the DWR call getUploadInfo() is
> called after the servlet is returned all the time. but if I set the
> activeReverseAjaxEnabled to false, the DWR call getUploadInfo() will be
> called before servlet doPost is done.
>
> Anybody has any clue about this issue?
>
> Thanks in advance.
>
> Dave
> --
> View this message in context:
> http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16764605.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
> For additional commands, e-mail: users-help@dwr.dev.java.net
>
>

Re: When activeReverseAjaxEnabled is true, long time delay for java call

by XMaNIaC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It seems you're hitting the two connections limit: one to upload the file, one for the progress bar and one for reverse AJAX. Currently no browser supports this beyond IE8 Beta 1 and FF3 beta5.

Regards

On Wed, Apr 23, 2008 at 7:40 PM, ddduuu <davidkdu@...> wrote:

Hi, XMaNIaC and all,

I am now using the DWR FileTransfer with the help of IWebMvc example to
upload files, but unfortunately, the problem is the same, when I set
activeReverseAjaxEnabled to true in web.xml, the getStatus() call will be
called after all the bytes of the file are transferred, so the progress bar
will not show the progress of the uploading process and only show 100% in
the end of the transferring process, and the file is transferred
successfully since I can see the file in the folder I configured.

also one more problem is that the file transfer will failed when the file is
too big like over 16MB.

The strange thing is that If I switch activeReverseAjaxEnabled to false,
then the progress bar can show the progress smoothly. I check my log file,
it shows getStatus() calls between the calls to update(long newBytesRead,
long newContentLength, int items) of SessionProgressListener (I added
logging messages in this method), but with activeReverseAjaxEnabled set to
true, the log file shows the getStatus() call is always in the end of the
file transferring and the all update() calls are already done with all bytes
read.

I think in the IWebMvc example, the problem exists as well, it is just a
small image file uploading finishes very fast, it is not easy to notice, but
with a bigger file, it should show the progress on the progress bar.

Here is the code block:
 uploadFile : function(record)
 {

     var  uploadFinished = function(status){
                       var data = {
                     record: record,
                     response: status
                   }
                   if (status.success) {
                     this.fsa.postEvent('file-upload-success', data);
                   }
                   else {
                     this.fsa.postEvent('file-upload-error', data);
                   }
     }
     UploadMonitor.upload(this.inputUploadFile,
uploadFinished.createDelegate(this));
      window.setTimeout("checkStatus()", 500);

 }

function checkStatus() {
   UploadMonitor.getStatus(updateProgress);
}

function updateProgress(data) {
       if(data){
               var percentage = (100 * data.bytesRead /
data.contentLength)|0;//can use parseInt(b/c)
               var progressbar = Ext.getCmp('uploadprogressid');
               progressbar.updateProgress(i,'Upload in progress: ' + percentage +
'%');
               if (percentage < 100)
                       window.setTimeout(checkStatus, 100);
      }else window.setTimeout(checkStatus, 100);

}

Thans very much and please help me solve the problem.

Dave


XMaNIaC wrote:
>
> Hi
>
> I would just use DWR FileTransfer and the progress bars it provides. Take
> a
> look at IWebMvc if you need some help.
>
> Regards,
>
> On Fri, Apr 18, 2008 at 9:37 PM, ddduuu <davidkdu@...> wrote:
>
>>
>> Hi, all,
>>
>> I have fileupload webapp with progress bar,  I upload the file through
>> Ext
>> ajax call to a servlet, which transfers file with commons-fileupload
>> library, I have a dwr call to retrieve the upload status from server side
>> with a callback function to update the progress bar, it works great when
>> I
>> set activeReverseAjaxEnabled to false, but when I set it to true, the dwr
>> call will always come back to call the callback javascript function after
>> the servlet returns and upload is already done at that point, so the
>> progress bar does not show any progress at all.
>>
>> I am not sure why the ReverseAjax prevented my dwr function from being
>> called immediately. I checked my log file, the DWR call getUploadInfo()
>> is
>> called after the servlet is returned all the time. but if I set the
>> activeReverseAjaxEnabled to false, the DWR call getUploadInfo() will be
>> called before servlet doPost is done.
>>
>> Anybody has any clue about this issue?
>>
>> Thanks in advance.
>>
>> Dave
>> --
>> View this message in context:
>> http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16764605.html
>> Sent from the DWR - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>
>

--
View this message in context: http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16834727.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: When activeReverseAjaxEnabled is true, long time delay for java call

by ddduuu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, got you, thanks for your response, that makes sense to me now.

Dave

XMaNIaC wrote:
It seems you're hitting the two connections limit: one to upload the file,
one for the progress bar and one for reverse AJAX. Currently no browser
supports this beyond IE8 Beta 1 and FF3 beta5.

Regards

On Wed, Apr 23, 2008 at 7:40 PM, ddduuu <davidkdu@gmail.com> wrote:

>
> Hi, XMaNIaC and all,
>
> I am now using the DWR FileTransfer with the help of IWebMvc example to
> upload files, but unfortunately, the problem is the same, when I set
> activeReverseAjaxEnabled to true in web.xml, the getStatus() call will be
> called after all the bytes of the file are transferred, so the progress
> bar
> will not show the progress of the uploading process and only show 100% in
> the end of the transferring process, and the file is transferred
> successfully since I can see the file in the folder I configured.
>
> also one more problem is that the file transfer will failed when the file
> is
> too big like over 16MB.
>
> The strange thing is that If I switch activeReverseAjaxEnabled to false,
> then the progress bar can show the progress smoothly. I check my log file,
> it shows getStatus() calls between the calls to update(long newBytesRead,
> long newContentLength, int items) of SessionProgressListener (I added
> logging messages in this method), but with activeReverseAjaxEnabled set to
> true, the log file shows the getStatus() call is always in the end of the
> file transferring and the all update() calls are already done with all
> bytes
> read.
>
> I think in the IWebMvc example, the problem exists as well, it is just a
> small image file uploading finishes very fast, it is not easy to notice,
> but
> with a bigger file, it should show the progress on the progress bar.
>
> Here is the code block:
>  uploadFile : function(record)
>  {
>
>      var  uploadFinished = function(status){
>                        var data = {
>                      record: record,
>                      response: status
>                    }
>                    if (status.success) {
>                      this.fsa.postEvent('file-upload-success', data);
>                    }
>                    else {
>                      this.fsa.postEvent('file-upload-error', data);
>                    }
>      }
>      UploadMonitor.upload(this.inputUploadFile,
> uploadFinished.createDelegate(this));
>       window.setTimeout("checkStatus()", 500);
>
>  }
>
> function checkStatus() {
>    UploadMonitor.getStatus(updateProgress);
> }
>
> function updateProgress(data) {
>        if(data){
>                var percentage = (100 * data.bytesRead /
> data.contentLength)|0;//can use parseInt(b/c)
>                var progressbar = Ext.getCmp('uploadprogressid');
>                progressbar.updateProgress(i,'Upload in progress: ' +
> percentage +
> '%');
>                if (percentage < 100)
>                        window.setTimeout(checkStatus, 100);
>       }else window.setTimeout(checkStatus, 100);
>
> }
>
> Thans very much and please help me solve the problem.
>
> Dave
>
>
> XMaNIaC wrote:
> >
> > Hi
> >
> > I would just use DWR FileTransfer and the progress bars it provides.
> Take
> > a
> > look at IWebMvc if you need some help.
> >
> > Regards,
> >
> > On Fri, Apr 18, 2008 at 9:37 PM, ddduuu <davidkdu@gmail.com> wrote:
> >
> >>
> >> Hi, all,
> >>
> >> I have fileupload webapp with progress bar,  I upload the file through
> >> Ext
> >> ajax call to a servlet, which transfers file with commons-fileupload
> >> library, I have a dwr call to retrieve the upload status from server
> side
> >> with a callback function to update the progress bar, it works great
> when
> >> I
> >> set activeReverseAjaxEnabled to false, but when I set it to true, the
> dwr
> >> call will always come back to call the callback javascript function
> after
> >> the servlet returns and upload is already done at that point, so the
> >> progress bar does not show any progress at all.
> >>
> >> I am not sure why the ReverseAjax prevented my dwr function from being
> >> called immediately. I checked my log file, the DWR call getUploadInfo()
> >> is
> >> called after the servlet is returned all the time. but if I set the
> >> activeReverseAjaxEnabled to false, the DWR call getUploadInfo() will be
> >> called before servlet doPost is done.
> >>
> >> Anybody has any clue about this issue?
> >>
> >> Thanks in advance.
> >>
> >> Dave
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16764605.html
> >> Sent from the DWR - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
> >> For additional commands, e-mail: users-help@dwr.dev.java.net
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/When-activeReverseAjaxEnabled-is-true%2C-long-time-delay-for-java-call-tp16764605p16834727.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
> For additional commands, e-mail: users-help@dwr.dev.java.net
>
>