Wicket: concurrent Ajax requests limited to one?

放肆的年华 提交于 2020-01-14 09:05:56

问题


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?


回答1:


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:


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).




回答3:


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.



来源:https://stackoverflow.com/questions/5856698/wicket-concurrent-ajax-requests-limited-to-one

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!