EN · DE · RU · FR · ES

#2774: MDefaultAjaxBehavior.java

projectforge-wicket/src/main/java/de/micromata/wicket/ajax/MDefaultAjaxBehavior.java Wicket Ajax Behavior (Micromata Extension) · projectforge-wicket/src/main/java/de/micromata/wicket/ajax/MDefaultAjaxBehavior.java 45 lines · 11 code · 29 comments · 5 blank
A thin wrapper around Wicket's AbstractDefaultAjaxBehavior with a single purpose: making the protected getCallbackScript() method publicly accessible. In Wicket's standard API, getCallbackScript() is protected and only callable from within the behavior's own rendering logic. The Micromata team needed to access this method from external callback wiring code — possibly for the FullCalendar integration or other client-side event bindings — and created this subclass that simply overrides getCallbackScript() to call the parent implementation with public visibility.

Architecture

The Visibility Hack Pattern

This is a classic Java visibility workaround: when a library (Wicket) makes a method protected but you need to call it from outside the inheritance hierarchy, you create a subclass that overrides the method and promotes its visibility to public. The overridden method does nothing except delegate to super.getCallbackScript(). This pattern is common in Wicket codebases where the framework's encapsulation prevents certain integration patterns.

Why It's Needed

Wicket's getCallbackScript() generates the JavaScript snippet that invokes the server-side callback URL with the correct parameters, anti-cache tokens, and Ajax settings. The FullCalendar integration (see files #2786-2790) needs to embed these callback scripts inside FullCalendar configuration JSON rather than attaching them as DOM event handlers. To do this, the callback script must be extracted from the behavior and interpolated into a different context — requiring public access to the script generation method.

Usage Context

Referenced from the FullCalendar callback system in net.ftlines.wicket.fullcalendar.callback.AbstractAjaxCallback (file #2789), which also extends AbstractDefaultAjaxBehavior and needs to manipulate the callback script for embedding in calendar event handlers.

Git History

CommitWhat changed
868d6abb7 through ceb63e8a1Six annual copyright header updates. The class itself — a single method override — has never required modification since the initial Wicket version migration. Its purpose is so narrowly defined that changes to Wicket's API would likely be absorbed without changes to this wrapper.