You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Lowery <sl...@gmail.com> on 2013/08/28 23:53:10 UTC

AjaxChannel usage

I would like to have my file upload requests on my site, which take much
longer than a normal request, go through a different mechanism.  I'd like
the user to still be able to click around the site and work while the file
is uploading and then when it finishes, I can pop up an "All Done" type
dialog.  AjaxChannel seems to me to be the mechanism to do this, but either
I am doing it wrong or it doesn't work as I'd expect.

My links I'm testing the concept with looks like (I'm using wicket 6.10.0):
add(new AjaxLink<Void>("slow") { @Override public void
onClick(AjaxRequestTarget target) { System.out.println("Slow Link
Clicked...."); try { Thread.sleep(Integer.valueOf("10000")); } catch
(InterruptedException ie) {} target.appendJavaScript("alert('Done with slow
running request');"); System.out.println("Done Processing Slow Link."); }
@Override protected void updateAjaxAttributes(AjaxRequestAttributes
attributes) { super.updateAjaxAttributes(attributes);
attributes.setChannel(new AjaxChannel("upl", AjaxChannel.Type.QUEUE)); }
}); add(new AjaxLink<Void>("fast") { @Override public void
onClick(AjaxRequestTarget target) { System.out.println("Fast Link
Clicked...."); target.appendJavaScript("alert('Done with fast running
request');"); System.out.println("Done Processing Fast Link."); } });

I would expect that if I click Slow, then click Fast that the fast would
return to the user before the slow, but that's not happening.

I can attach a quickstart and create an issue in JIRA if that is the route
to go if I am doing it right.  If I'm doing it wrong, can someone let me
know how I can accomplish what I'm looking to do?

Thanks,
Steve

Re: AjaxChannel usage

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Aug 29, 2013 at 2:28 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi Steve,
>
> Wicket serializes requests to pages, so Ajax channels won't help you for
> long running processes.
>
> You'll have to upload the file to a resource, so the user can continue to
> work on the page. You'll probably need an iframe for that, see:
>
> http://stackoverflow.com/**questions/166221/how-can-i-**
> upload-files-asynchronously-**with-jquery<http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery>


http://wicketinaction.com/2012/11/uploading-files-to-wicket-iresource/ may
be useful too.


>
>
> Regards
> Sven
>
>
>
> On 08/28/2013 11:53 PM, Steve Lowery wrote:
>
>> I would like to have my file upload requests on my site, which take much
>> longer than a normal request, go through a different mechanism.  I'd like
>> the user to still be able to click around the site and work while the file
>> is uploading and then when it finishes, I can pop up an "All Done" type
>> dialog.  AjaxChannel seems to me to be the mechanism to do this, but
>> either
>> I am doing it wrong or it doesn't work as I'd expect.
>>
>> My links I'm testing the concept with looks like (I'm using wicket
>> 6.10.0):
>> add(new AjaxLink<Void>("slow") { @Override public void
>> onClick(AjaxRequestTarget target) { System.out.println("Slow Link
>> Clicked...."); try { Thread.sleep(Integer.valueOf("**10000")); } catch
>> (InterruptedException ie) {} target.appendJavaScript("**alert('Done with
>> slow
>> running request');"); System.out.println("Done Processing Slow Link."); }
>> @Override protected void updateAjaxAttributes(**AjaxRequestAttributes
>> attributes) { super.updateAjaxAttributes(**attributes);
>> attributes.setChannel(new AjaxChannel("upl", AjaxChannel.Type.QUEUE)); }
>> }); add(new AjaxLink<Void>("fast") { @Override public void
>> onClick(AjaxRequestTarget target) { System.out.println("Fast Link
>> Clicked...."); target.appendJavaScript("**alert('Done with fast running
>> request');"); System.out.println("Done Processing Fast Link."); } });
>>
>> I would expect that if I click Slow, then click Fast that the fast would
>> return to the user before the slow, but that's not happening.
>>
>> I can attach a quickstart and create an issue in JIRA if that is the route
>> to go if I am doing it right.  If I'm doing it wrong, can someone let me
>> know how I can accomplish what I'm looking to do?
>>
>> Thanks,
>> Steve
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: AjaxChannel usage

Posted by Sven Meier <sv...@meiers.net>.
Hi Steve,

Wicket serializes requests to pages, so Ajax channels won't help you for 
long running processes.

You'll have to upload the file to a resource, so the user can continue 
to work on the page. You'll probably need an iframe for that, see:

http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery

Regards
Sven


On 08/28/2013 11:53 PM, Steve Lowery wrote:
> I would like to have my file upload requests on my site, which take much
> longer than a normal request, go through a different mechanism.  I'd like
> the user to still be able to click around the site and work while the file
> is uploading and then when it finishes, I can pop up an "All Done" type
> dialog.  AjaxChannel seems to me to be the mechanism to do this, but either
> I am doing it wrong or it doesn't work as I'd expect.
>
> My links I'm testing the concept with looks like (I'm using wicket 6.10.0):
> add(new AjaxLink<Void>("slow") { @Override public void
> onClick(AjaxRequestTarget target) { System.out.println("Slow Link
> Clicked...."); try { Thread.sleep(Integer.valueOf("10000")); } catch
> (InterruptedException ie) {} target.appendJavaScript("alert('Done with slow
> running request');"); System.out.println("Done Processing Slow Link."); }
> @Override protected void updateAjaxAttributes(AjaxRequestAttributes
> attributes) { super.updateAjaxAttributes(attributes);
> attributes.setChannel(new AjaxChannel("upl", AjaxChannel.Type.QUEUE)); }
> }); add(new AjaxLink<Void>("fast") { @Override public void
> onClick(AjaxRequestTarget target) { System.out.println("Fast Link
> Clicked...."); target.appendJavaScript("alert('Done with fast running
> request');"); System.out.println("Done Processing Fast Link."); } });
>
> I would expect that if I click Slow, then click Fast that the fast would
> return to the user before the slow, but that's not happening.
>
> I can attach a quickstart and create an issue in JIRA if that is the route
> to go if I am doing it right.  If I'm doing it wrong, can someone let me
> know how I can accomplish what I'm looking to do?
>
> Thanks,
> Steve
>


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