Wicket:并发 Ajax 请求仅限于一个?

发布于 2024-11-05 04:50:39 字数 380 浏览 1 评论 0原文

情况

在我的 Wicket 应用程序中,我有一个包含两个标签的页面。每次选择一个选项卡时,都会通过 Ajax 获取其内容,以便每次切换到不同的选项卡时,都会从服务器新鲜加载其内容。

在其中一个选项卡上,我有一个输入字段,其中有一个 onblur 事件,该事件通过 Ajax 保存该字段的内容。

问题

如果焦点位于输入字段上,并且我单击页面的空白区域,则会触发 Ajax 请求并保存数据。

如果我不是单击页面的空白区域,而是单击另一个选项卡,则会触发保存输入字段的 Ajax 请求,但不会触发切换选项卡的 Ajax 请求。

Wicket 中的并发 Ajax 请求数是否限制为 1?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

放血 2024-11-12 04:50:39

是的,对页面实例的并发请求仅限于一个。 Wicket Ajax 将在客户端通道中对后续 Ajax 请求进行排队。有关正在运行的应用程序的详细信息,请参阅 wicket Ajax 调试器。

这样做是为了使构建应用程序更容易:无需解决服务器上的并发问题。页面访问始终由一个线程完成:当前活动的请求线程。如果我们不这样做,我们就必须在组件树上进行同步,并使整个编程模型变得糟糕。

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.

丢了幸福的猪 2024-11-12 04:50:39

问题是我们的 AjaxIndicator 在每个 Ajax 请求期间在整个页面上覆盖了一个 DIV。当覆盖层就位时,“mouseup”(以及随后的“click”)事件到达,因此丢失。通过按住鼠标按钮并在第一个 Ajax 请求完成并删除覆盖 DIV 后松开鼠标按钮,将触发第二个 Ajax 请求。

现在看来很明显,因为我们有这样一个覆盖层的全部原因是为了防止用户在 Ajax 请求运行时点击。

我认为我的解决方案是在某些非常快速的请求上禁用 ajax 指示器,例如在这些请求中没有指示器的情况(忽略在服务器负载异常高的情况下请求可能需要更长时间的可能性)。

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

迟月 2024-11-12 04:50:39

可能是 onblur ajax 请求的响应可能有错误,或者您在 ajax 响应后执行的过程可能有错误。

如果可能的话,您可以粘贴代码片段。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文