EN · DE · RU · FR · ES

#2773: AjaxFormSubmitCallback.java

projectforge-wicket/src/main/java/de/micromata/wicket/ajax/AjaxFormSubmitCallback.java Java Interface (Micromata Wicket Ajax Form) · projectforge-wicket/src/main/java/de/micromata/wicket/ajax/AjaxFormSubmitCallback.java 39 lines · 7 code · 28 comments · 4 blank
A specialization of AjaxCallback for Wicket form submission scenarios. Extends the basic callback contract with an onError(AjaxRequestTarget, Form<?>) method that fires when form validation fails. This interface separates the success path (inherited callback method) from the error path (new onError method), following the template method pattern at the interface level. Implementations receive both the Ajax target (to update error messages in the DOM) and the form instance (to inspect validation errors).

Architecture

Two-Phase Callback Pattern

The separation of success and error handling at the interface level is deliberate. Wicket forms operate in a two-phase validation cycle: first the form validates, then either the success or error handler runs. By encoding both outcomes in the interface contract, calling code in Micromata's custom Ajax behaviors can unconditionally invoke the appropriate method based on the form's validation state, without needing reflection or instanceof checks.

Serialization Requirement

Like its parent AjaxCallback, this interface extends Serializable. In Wicket's page store architecture (which may serialize pages to disk or a database between requests), callback implementations must survive serialization. This is a common Wicket constraint — any object attached to a component tree must implement Serializable.

Git History

CommitWhat changed
868d6abb7 through ceb63e8a1Six annual copyright header updates (2001-2021 → 2001-2026), spanning the full history of the file. The interface itself has never been modified beyond its initial creation — the form submit callback contract has proven sufficient for all form handling scenarios in the application.