Ajax: publish a topic when a call waits in its channel's queue, and when a call is dropped without being sent

Đang mở
#1,942 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, javascript
Lĩnh vực
frontend, web-dev

Hướng nghiên cứu

Start with wicket-ajax.js, especially Wicket.Ajax.Call#ajax, Wicket.Channel, and Wicket.Throttler; trace how calls are queued, replaced, or ignored. Then inspect IAjaxCallListener, AjaxCallListener, and PageVeilBehavior for how existing topics are declared and handled. Done means the queued and dropped topics report the described call details and reasons, with the stated exactly-once completion guarantee.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Affects: 11.0.0 and current master; the same code in 10.x.
Component: wicket-core, wicket-ajax.js (Wicket.Ajax.ajax, Wicket.Ajax.Call#ajax, Wicket.Channel, Wicket.Throttler), IAjaxCallListener; wicket-extensions, PageVeilBehavior

What happens

A script cannot follow an Ajax call from the moment it is asked for to the moment it ends, because some of the call's life is never published:

  • /ajax/call/init is published only by the handlers Wicket.Ajax.ajax binds to events, before throttling. A call made with Wicket.Ajax.get/post or new Wicket.Ajax.Call().ajax(attrs) publishes nothing until doAjax runs.

  • Wicket.Ajax.Call#ajax hands the call to its channel. When the channel is busy, the call waits in its queue (s), replaces the calls waiting there (d), or is ignored (a). Nothing is published for any of these.

  • /ajax/call/before through /ajax/call/done are published from doAjax, which runs only once the channel is free.

  • Some calls never run, and publish nothing at all, not even /ajax/call/done:

    • a call dropped from a d channel's queue;
    • a call ignored by an a channel;
    • a throttled call replaced by a later one (Wicket.Throttler#throttle, entry.setFunc(func)).

    A call stopped by its precondition does publish done.

So init misses calls, and is not always followed by done. beforeSend comes after the call has waited in the queue.

Why it matters

The page veil of PageVeilBehavior (#1631) goes up at /ajax/call/beforeSend. Suppose a request that is not veiled is running: a filter, a timer, or a call with wicket_nb. A click on a button then waits in the channel's queue with no veil over the page, and a second click waits behind it. Once the channel is free, both run, and the action runs twice. That is the case the veil is there for.

Raising the veil at /ajax/call/init instead does not work either. After a throttled or dropped call it stays up for good, since no topic tells it the call is gone. The same holds for any busy indicator, or a guard against double submits, written on the global topics.

Proposal

Two topics, with their handlers in IAjaxCallListener and AjaxCallListener like the other topics:

  • /ajax/call/queued (Wicket.Event.Topic.AJAX_CALL_QUEUED): published when the channel makes the call wait behind a running one. The call's attributes and the channel's name are passed with it. The handler is getQueuedHandler(Component) / onQueued(...).

  • /ajax/call/dropped (Wicket.Event.Topic.AJAX_CALL_DROPPED): published when a call will never run, for any of these reasons:

    • removed from a d channel's queue;
    • ignored by an a channel;
    • replaced in the throttler.

    The dropped call's attributes and the reason are passed with it. The handler is getDroppedHandler(Component) / onDropped(...).

The guarantee that comes with them: every call that publishes init or queued ends with exactly one done or dropped.

PageVeilBehavior could then raise its veil at init or queued, for the calls not opted out, and lower it at done or dropped. A click waiting behind another request is then veiled, and so is the click that would queue behind it.

Workaround

Today the only way is to wrap Wicket.Channel.prototype.schedule and Wicket.Throttler.prototype.throttle, which are internal and may change.

Found while working on reiern70/advanced-widgets#141.

Ngôn ngữ chính
Java
Star
800
Fork
437
Merge trung bình
21 giờ 36 phút
Pull request đã merge (30 ngày)
167

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/wicket

Tất cả issue của apache/wicket

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.