EN · DE · RU · FR · ES

#2789: AbstractAjaxCallback.java

projectforge-wicket/src/main/java/net/ftlines/wicket/fullcalendar/callback/AbstractAjaxCallback.java Abstract Wicket Behavior (FullCalendar Ajax Callback base) · projectforge-wicket/src/main/java/net/ftlines/wicket/fullcalendar/callback/AbstractAjaxCallback.java 65 lines · 18 code · 37 comments · 10 blank
The abstract base class for all FullCalendar Ajax callback behaviors. Extends Wicket's AbstractDefaultAjaxBehavior and provides an essential URL/script manipulation mechanism: it appends a placeholder token (<PLACEHOLDER>) to both the callback URL and callback script, which concrete subclasses replace with event-specific data (like event IDs, source UUIDs, or date ranges) through the abstract configureCallbackScript method. This enables dynamically-generated callback scripts that embed event identifiers directly in the JavaScript function body, rather than relying on Wicket's standard parameter-passing mechanism, which is necessary because FullCalendar invokes these callbacks with its own argument convention.

Architecture

Placeholder Pattern

The core idea: Wicket generates a callback URL like /wicket/page?3-1.IBehaviorListener.0-calendar<PLACEHOLDER> and a callback script like function() { Wicket.Ajax.ajax({'u':'...<PLACEHOLDER>'}) }. The configureCallbackScript(String script, String urlTail) method (implemented by subclasses) replaces <PLACEHOLDER> in the script with FullCalendar-appropriate logic and the urlTail parameter (which is the full URL with placeholder) with the appropriately modified URL.

The placeholder is appended to getCallbackUrl() via string concatenation — Wicket's URL encoding preserves it literally. The getCallbackScript() override intercepts Wicket's script generation and passes both the script and the placeholder-augmented URL to the subclass for customization.

Subclass Contract

Concrete callbacks must implement configureCallbackScript(String script, String urlTail). The script parameter is the Wicket-generated callback JavaScript; urlTail is the full callback URL with <PLACEHOLDER> appended. Subclasses replace the placeholder with event-specific JavaScript expressions (e.g., concatenating an event ID variable from FullCalendar's callback arguments).

Calendar Access

The getCalendar() helper casts getComponent() to FullCalendar, providing subclasses with access to the calendar instance, its configuration, and its event manager. This is used by callbacks that need to look up events or modify the calendar state.

Package-Private Visibility

The class and its abstract methods are package-private — callbacks are internal to the callback package. External code interacts through the FullCalendar template methods and the Config callback model, not directly with behavior classes.

Git History

CommitWhat changed
868d6abb7 through ceb63e8a1Six annual copyright header updates. The placeholder-based callback URL/script manipulation pattern has been stable — it encapsulates the core integration challenge between Wicket's Ajax behavior system and FullCalendar's JavaScript callback conventions.