You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Zardecki <mp...@truecool.com> on 2010/10/20 06:22:32 UTC

Long running task with download

Hi List, I have an interesting problem, I have a long running task where I build a zip file out of data which I then want to download to the user.

I have a dialog on my main windows which builds the zip file fine while providing feedback (using a ModalWindow and Wicket AJAX) but I'm then finding myself unable to send the zip file back to the user.

The RequestCycle (to get the Web response) is unavailable inside my zip file building thread (as it's ThreadLocal) and if I try passing the RequestCycle to my thread I get error stating that RequestCycle is non serializable.

I'm playing around trying to build the zip file in the thread/dialog then downloading from the main window but still experiencing some issues.

Any advice or tips? Should I be able to access RequectCycle and just send the zip file inside the ModalWindow without creating a separate thread to zip the file?

Thanks,

Martin


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


Re: Long running task with download

Posted by Martin Zardecki <mp...@truecool.com>.
Yeah, I close the modal window first and this works on Safari but still gives
the message on Firefox.

Go figure.

Thanks again.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Long-running-task-with-download-tp3003232p3004771.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Long running task with download

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
try closing the modal window first: this is the source of the navigate
away message (I guess),

Ernesto

On Wed, Oct 20, 2010 at 5:18 PM, Martin Zardecki <mp...@truecool.com> wrote:
>
> I had the whole zip + download working from a simple link but building the
> zip file could take a while and without feedback the user might try
> refreshing the screen or something stupid which is why I wanted to have a
> progress status update.
>
> Using that AjaxDownload behavior fixed my issue and it works now, I guess I
> needed to create another request/response for the download to work....I
> couldn't just start the download inside an AjaxButton.onSubmit method.
>
> The only downside is on some browsers it asks "Are you sure you want to
> navigate away from this page" due to the redirect in the AjaxDownload
> behavior.
>
> Thanks.
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Long-running-task-with-download-tp3003232p3004093.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Long running task with download

Posted by Martin Zardecki <mp...@truecool.com>.
I had the whole zip + download working from a simple link but building the
zip file could take a while and without feedback the user might try
refreshing the screen or something stupid which is why I wanted to have a
progress status update.

Using that AjaxDownload behavior fixed my issue and it works now, I guess I
needed to create another request/response for the download to work....I
couldn't just start the download inside an AjaxButton.onSubmit method.

The only downside is on some browsers it asks "Are you sure you want to
navigate away from this page" due to the redirect in the AjaxDownload
behavior.

Thanks.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Long-running-task-with-download-tp3003232p3004093.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Long running task with download

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Maybe [1] will be useful for the final step. Or maybe just replace
your progress reporting panel with a panel containing a download link.

Ernesto

1-https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow

On Wed, Oct 20, 2010 at 6:22 AM, Martin Zardecki <mp...@truecool.com> wrote:
> Hi List, I have an interesting problem, I have a long running task where I build a zip file out of data which I then want to download to the user.
>
> I have a dialog on my main windows which builds the zip file fine while providing feedback (using a ModalWindow and Wicket AJAX) but I'm then finding myself unable to send the zip file back to the user.
>
> The RequestCycle (to get the Web response) is unavailable inside my zip file building thread (as it's ThreadLocal) and if I try passing the RequestCycle to my thread I get error stating that RequestCycle is non serializable.
>
> I'm playing around trying to build the zip file in the thread/dialog then downloading from the main window but still experiencing some issues.
>
> Any advice or tips? Should I be able to access RequectCycle and just send the zip file inside the ModalWindow without creating a separate thread to zip the file?
>
> Thanks,
>
> Martin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Long running task with download

Posted by Alex Objelean <al...@gmail.com>.
One small note about running a background thread is that inside that thread
you cannot access the Application instance (Application.get()), because it
is not an inheritable thread local. It may be a problem in some cases.

Alex
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Long-running-task-with-download-tp3003232p3003347.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Long running task with download

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Tue, Oct 19, 2010 at 11:22 PM, Martin Zardecki <mp...@truecool.com>wrote:

> Hi List, I have an interesting problem, I have a long running task where I
> build a zip file out of data which I then want to download to the user.
>
> I have a dialog on my main windows which builds the zip file fine while
> providing feedback (using a ModalWindow and Wicket AJAX) but I'm then
> finding myself unable to send the zip file back to the user.
>
> The RequestCycle (to get the Web response) is unavailable inside my zip
> file building thread (as it's ThreadLocal) and if I try passing the
> RequestCycle to my thread I get error stating that RequestCycle is non
> serializable.
>
> I'm playing around trying to build the zip file in the thread/dialog then
> downloading from the main window but still experiencing some issues.
>
> Any advice or tips? Should I be able to access RequectCycle and just send
> the zip file inside the ModalWindow without creating a separate thread to
> zip the file?
>
> Thanks,
>
> Martin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
I'm assuming the zip is being created in a background thread?  It also
sounds like you already have AJAX polling created to monitor the progress of
file creation.  If so, you're on the right track.

Typically, one of the easiest ways to do this is:
background thread -> doing long task
AJAX timer behavior -> checking status of background job, updating UI to
show status updates

When the job is done, the AJAX timer behavior does a redirect to the
download, opens a window to the download, etc... with javascript

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*