Wicket: concurrent Ajax requests limited to one?

Situation

In my Wicket app, I have a page containing two tags. Each time a tab is selected, its contents are selected through Ajax, so every time you switch to another tab, its contents are downloaded from the server.

On one of the tabs, I have an input field in which there is an onblur event that saves the contents of the field through Ajax.

Problem

If the focus is in the input field and I click on an empty area of ​​the page, the Ajax request is launched and the data is saved.

If instead of clicking on an empty area of ​​the page I click on another tab, the Ajax request to save the input field is launched, but not the Ajax request to switch the tabs.

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

+6
source share
3 answers

The problem was our AjaxIndicator, which imposes a DIV on the entire page throughout each Ajax request. The mouseup events (and therefore click) came when the overlay was in place and thus lost. By holding down the mouse button and releasing it after the first Ajax request has been completed and the DIV has been deleted, the second ajax request has been launched.

Now it seems obvious that the whole reason we have such an overlay is to prevent users from clicking while the Ajax request is running.

I think that my solution will be to turn off the ajax indicator on certain, very fast requests, for example, where it makes no sense to have an indicator (without taking into account the probability that requests can take much longer in case of unusually high load server).

+3
source

Yes, simultaneous requests to the page instance are limited to one. Wicket Ajax will host subsequent Ajax requests on the client side channel. See the Ajax debugger for the gate for details in your running application.

This is done to simplify the creation of the application: there is no need to bypass concurrency problems on the server. Access to the page is always performed by a single thread: the current thread of active requests. If we hadn’t done this, we would have to synchronize in the component tree and make the whole yuk programming model.

+9
source

Maybe the response to the onblur ajax request may have an error or the process that you are executing after the ajax response may have an error.

If possible, you can embed sniplet code.

0
source

Source: https://habr.com/ru/post/887116/


All Articles