6

Situation

In my Wicket application, I have a page which contains two tags. Each time a tab is selected, its content is fetched via Ajax so that every time you switch to a different tab its content it loaded fresh from the server.

On one of the tabs I have an input field which has an onblur event which saves the contents of the field via Ajax.

Problem

If the focus is on the input field and I click to a blank area of the page, the Ajax request it fired and the data saved.

If, instead of clicking on a blank area of the page, I click on the other tab, the Ajax request to save the input field is fired but not the Ajax request to switch tabs.

Is the number of concurrent Ajax requests limited in Wicket to one?

3 Answers 3

10

Yes, concurrent requests to a page instance are limited to one. Wicket Ajax will queue subsequent Ajax requests in the client side channel. See the wicket Ajax debugger for details in your running application.

This is done to make building your application easier: no need to work around concurrency issues on the server. Page access is always one done from one single thread: the current active request thread. If we didn't do this, we would have to synchronize on the component tree and make the whole programming model go yuk.

2
  • Thanks - that makes sense, but it doesn't explain why the request to change the tab isn't fired. Is the queue size limited to 1? I checked the channel name and both use "0|s". Commented May 2, 2011 at 12:50
  • 1
    As an aside, although doing it on a framework level would be very painful, in certain, limited cases you can roll your own self-updating components that run in parallel with relatively little fuss.
    – biziclop
    Commented Nov 5, 2012 at 20:12
4

The problem was our AjaxIndicator which overlays a DIV over the entire page for the duration of each Ajax request. The "mouseup" (and consequently "click") events arrived when the overlay was in place, and thus lost. By holding the mouse button down and releasing it after the first Ajax request had completed and overlaying DIV removed, the second ajax request was fired.

It seems obvious now as the whole reason why we have such an overlay is to prevent users clicking while an Ajax request is running.

I think my solution will be to disable the ajax indicator on certain, very quick requests such as these where it makes no sense to have an indicator (disregarding the potential that requests could take much longer in case of unusually high server load).

0

May be the response of the onblur ajax request may have error or the process you are performing after the ajax response may have error.

If possible can you paste the code sniplet.

1
  • Thanks for your reply - neither requests when executed individually produce an error. I'm currently reading wicket-ajax.js and there appears to be some sort of queuing going on there... Commented May 2, 2011 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.