EN · DE · RU · FR · ES

#2772: AjaxCallback.java

projectforge-wicket/src/main/java/de/micromata/wicket/ajax/AjaxCallback.java Java Interface (Micromata Wicket Ajax) · projectforge-wicket/src/main/java/de/micromata/wicket/ajax/AjaxCallback.java 40 lines · 7 code · 28 comments · 5 blank
A simple functional interface (single abstract method) that defines the contract for Micromata's custom Wicket Ajax callback handling. Any class implementing AjaxCallback must provide a callback(AjaxRequestTarget) method that receives Wicket's AjaxRequestTarget — the standard Wicket object for composing Ajax responses (appending JavaScript, adding components for re-render, etc.). The interface extends Serializable, which is required because Wicket may serialize callback instances as part of page state in its session or disk-based page store.

Architecture

Why a Custom Callback Interface?

Wicket provides its own callback mechanisms (AbstractDefaultAjaxBehavior, AjaxEventBehavior, etc.), but they are tied to specific component lifecycle hooks. The Micromata team created a simpler, detached callback abstraction that can be passed around independently of Wicket components. This interface is consumed by classes like MDefaultAjaxBehavior that bridge between the lightweight callback contract and Wicket's behavior/lifecycle system.

Relationship to AjaxFormSubmitCallback

The companion interface AjaxFormSubmitCallback (file #2773) extends this interface, adding an onError method for form submission error handling. This follows the Command pattern: the basic callback is the command interface, and the form variant adds error handling as a specialization.

Git History

CommitWhat changed
868d6abb7 through ceb63e8a1Six annual copyright header updates (2001-2021 → 2001-2026). The interface contract has not changed — only the copyright year range in the file header has been incremented annually. This is one of the most stable files in the wicket module.