reiern70 opened a new issue, #1631:
URL: https://github.com/apache/wicket/issues/1631

   # Add Ajax veil behaviors that block the page, or a component, while a 
request runs
   
   ## Problem
   
   Wicket has no built-in way to stop the user from interacting with a page 
while an Ajax request is running. An activity indicator (`IndicatingAjaxLink`, 
`AjaxIndicatorAppender`) shows that something is happening, but a second click 
on a slow button still sends the request again, and a click elsewhere can act 
on markup the pending response is about to replace. 
`AjaxDisableComponentListener` covers only the component that fired the 
request. Applications end up writing their own veil on top of the global Ajax 
topics.
   
   ## Proposal
   
   Two behaviors in a new package `org.apache.wicket.extensions.ajax.veil` in 
wicket-extensions:
   
   - **`PageVeilBehavior`**, added to a page (typically a base page): veils the 
whole page during every Ajax request fired from it. Adding it to anything but a 
`Page` throws `IllegalArgumentException`.
   - **`LocalVeilBehavior`**, added to any component: veils only that 
component, and only during requests fired from the component or from a 
component nested in it. Such a request does not veil the page. Nested local 
veils: the innermost one takes the request. It sets `setOutputMarkupId(true)`.
   
   ### Behaviour
   
   - The veil appears as soon as the request is sent (`/ajax/call/beforeSend`) 
and goes away when it is done (`/ajax/call/done`, which fires on success and on 
failure). It is **transparent and swallows mouse clicks**, so a fast request 
does not make the page flash.
   - If the request is still running after **300 ms**, the veil gets the class 
`wicket-veil-busy`: it dims the region and shows a CSS spinner.
   - Once shown, the spinner stays for at least **500 ms**, so a response 
arriving just after it appeared does not make it flicker.
   - Concurrent requests share one veil, removed when the last one is done.
   - The keyboard is not intercepted.
   
   ### Opting out
   
   `PageVeilBehavior.noVeil(AjaxRequestAttributes)` adds the extra parameter 
`wicket_nb` (`PageVeilBehavior.NO_VEIL_PARAMETER`) to a request. Such a request 
is left alone by the page veil and by every local veil. Background requests 
(timers, lazy loading panels) are veiled too unless they opt out this way.
   
   ### Customization
   
   - Timings: `protected Duration getSpinnerDelay()` and 
`getMinimumSpinnerTime()` on the common base class `AbstractVeilBehavior`.
   - Look: `wicket-veil.css` with the classes `wicket-veil`, `wicket-veil-busy` 
and `wicket-veil-host` (the latter gives a locally veiled element `position: 
relative`).
   
   ### Client side
   
   `wicket-veil.js` (`Wicket.Veil.page(options)` / `Wicket.Veil.local(markupId, 
options)`) subscribes to the global Ajax topics, so it works with both the 
jQuery-based and the plain JavaScript Ajax engine. No change to wicket-core.
   
   ## Scope
   
   - New API only, nothing changed or removed, so no migration is needed.
   - An example page in wicket-examples (`ajax/veil`) and a section in the user 
guide's Ajax chapter.
   - Tests: Java tests for the rendered contributions, QUnit tests for 
`Wicket.Veil` (both engines, fake clock), and Selenium tests driving the 
example page in headless Chrome.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to