EN · DE · RU · FR · ES

#2778: CalendarResponse.java

projectforge-wicket/src/main/java/net/ftlines/wicket/fullcalendar/CalendarResponse.java Java Response Builder (FullCalendar Ajax Commands) · projectforge-wicket/src/main/java/net/ftlines/wicket/fullcalendar/CalendarResponse.java 110 lines · 48 code · 43 comments · 19 blank
A fluent API for sending commands from the Wicket server to the FullCalendar JavaScript client in response to Ajax callbacks. Each method composes a jQuery-based JavaScript invocation targeting the calendar's DOM element ($('#calendarId').fullCalendarExt("command", args...)) and appends it to Wicket's AjaxRequestTarget. This is the server-to-client command channel for calendar manipulation: refreshing events, toggling event source visibility, removing events, navigating to dates, and clearing selections — all driven from server-side event handlers that react to user interactions.

Architecture

Command Builder Pattern

Every public method returns CalendarResponse for chaining. The pattern enables composing multiple calendar commands in a single callback handler:

response.clearSelection().gotoDate(date).refetchEvents();

The underlying mechanism generates JavaScript strings via execute(args...), which uses String.format to produce a jQuery selector targeting the calendar's Wicket markup ID, and appends the JavaScript to the AjaxRequestTarget. The q() helper wraps arguments in single quotes (or outputs null for null values).

Available Commands

Architecture Note: Single-Event Optimization

The refetchEvent method contains a TODO comment acknowledging the current unoptimized implementation (refetching the entire source). The comment outlines the planned optimization: searching for the affected event in the client-side buffer and refetching only that event. This is a recognized performance TODO for calendars with many events.

Git History

CommitWhat changed
868d6abb7 through ceb63e8a1Six annual copyright header updates. The command set and fluent API have remained stable — the FullCalendar extension script's command vocabulary covers the needs of the calendar integration, and no new server-to-client commands have been required.