AbstractAjaxCallbackWithClientsideRevert.javaFullCalendar implements optimistic UI updates: the event moves immediately on drag, and the server can accept (nothing changes) or reject (event reverts to original position). This class implements the server side of that protocol:
onEvent(AjaxRequestTarget) is called — the subclass implements business logic and returns true (accept) or false (reject)$.data(document, '{uuid}', {boolean})getRevertScript() method)A random UUID (prefixed with "u") identifies the callback instance. This UUID is used as a jQuery data key to store the boolean result. This avoids global state collisions when multiple calendar instances or multiple callback types are on the same page. The UUID is generated once in the field initializer and persists for the behavior's lifetime.
updateAjaxAttributes() is overridden to add two listeners:
onSuccess — executes the success script which conditionally triggers the revertonFailure — unconditionally executes the revert script (network/server errors always revert)Concrete subclasses must implement:
getRevertScript() — returns the FullCalendar JavaScript expression that reverts the event to its original state (e.g., $('#calendar').fullCalendarExt('revertEvent', eventId))onEvent(AjaxRequestTarget) — the business logic for accepting/rejecting the change| Commit | What changed |
|---|---|
868d6abb7 through ceb63e8a1 | Six annual copyright header updates. The two-phase commit protocol and UUID-based state channel have been stable — the mechanism correctly handles FullCalendar's optimistic update pattern and distinguishes between business rule rejections (server returns false) and infrastructure failures (Ajax error triggers unconditional revert). |