Class CalendarDef
- All Implemented Interfaces:
Widget
This is the Widget marker type — the juneau-console-widgets
org.apache.juneau.console.widgets.Widget, not org.apache.juneau.marshall.html.HtmlWidget
(the unrelated $W{...} HTML header-widget SPI). It is bean-only: the emitter
(CalendarTable) and the juneau-calendar.js/.css runtime live in
juneau-console-views, which composes this bean. Widgets keeps no dependency on views.
The server renders the initial month grid + legend and paints real seed chips into the day cells (progressive
enhancement); the runtime then computes each month client-side and hydrates events from a same-origin, data-only
per-month GET whose envelope is {contractVersion, year, month, events}. When endpoint is
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe view families; v1 shipsMONTHonly so an author cannot set a value that only fails atvalidate().static enumThe first column of the week grid. -
Field Summary
FieldsModifier and TypeFieldDescriptionDeclared event categories, in legend display order.static final StringThe frozen contract version for the per-month event GET envelope and the stampeddata-juneau-calendar-contractattribute.static final intThe default chip cap per day cell before collapsing into "+N more".Same-origin path template for the per-month event GET; must contain{year}and{month}.Optional initial-month seed events, painted into the initial month server-side and embedded as the sidecar.Required, non-blank instance id; charset[A-Za-z][A-Za-z0-9_-]*.Optional 1-based initial month (1..12); paired withinitialYear.Optional initial year; paired withinitialMonth.static final intThe hard internal ceiling on spanning-bar lanes in one week row.Optional max chips per day before "+N more"; defaults toDEFAULT_MAX_PER_DAY.Which view to render; v1 supportsCalendarDef.CalendarView.MONTHonly.First column of the week grid; defaults toCalendarDef.WeekStart.SUNDAY. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncategories(EventCategory... value) Sets the declared categories, in legend order.static CalendarDefcreate()Creates an empty calendar definition.intThe per-week-row spanning-bar lane budget —effectiveMaxPerDay()clamped toMAX_LANES_PER_WEEK.intThe effective chip cap — the declaredmaxPerDayorDEFAULT_MAX_PER_DAYwhen unset.The effective view — the declaredvieworCalendarDef.CalendarView.MONTHwhen unset.The effective week start — the declaredweekStartorCalendarDef.WeekStart.SUNDAYwhen unset.Sets the per-month event GET template.events(CalendarEvent... value) Sets the initial-month seed events.Sets the instance id.initial(int year, int month) Sets the initial year and 1-based month together.maxPerDay(int value) Sets the max chips per day before "+N more".voidvalidate()Fail-closed bean validation.voidFail-closed bean validation against a resolved (year, month) window.view(CalendarDef.CalendarView value) Sets the view.weekStart(CalendarDef.WeekStart value) Sets the week start column.The seed events that are well-formed enough to paint — the malformed ones are dropped, exactly as a per-month GET handler drops them viaCalendarEvent.retainWellFormed(Collection).
-
Field Details
-
CONTRACT_VERSION
The frozen contract version for the per-month event GET envelope and the stampeddata-juneau-calendar-contractattribute. Serialized as the JSON string"2"(a numeric2would fail the client's strict===handshake).Bumped from
"1"to"2"for theend-becomes-layout-significant change even though the envelope gained no new required field (endwas already carried for forward-compat). The bump is justified because this same constant is the stampeddata-juneau-calendar-contractattribute: a v1 runtime paired with a v2 server would silently ignoreendand paint a multi-day event as a single chip, so making the handshake fail loud is the point. Do not copy this as a general pattern — a wire contract that is not also a runtime-handshake stamp should not bump for a no-new-field change.- See Also:
-
DEFAULT_MAX_PER_DAY
The default chip cap per day cell before collapsing into "+N more".- See Also:
-
MAX_LANES_PER_WEEK
The hard internal ceiling on spanning-bar lanes in one week row.The lane budget is derived from
effectiveMaxPerDay()and clamped here; it is deliberately not author-controllable (there is nomaxLanesPerWeekbean field). Bars that would need a lane beyond the budget are collapsed into the day cells' "+N more" affordance instead of stacking a week row arbitrarily tall.- See Also:
-
id
Required, non-blank instance id; charset[A-Za-z][A-Za-z0-9_-]*. Emitted asdata-juneau-calendar. -
endpoint
Same-origin path template for the per-month event GET; must contain{year}and{month}. May benull : seed-only, with month navigation disabled. -
categories
Declared event categories, in legend display order. A referencedcategoryIdmust be declared here. -
events
Optional initial-month seed events, painted into the initial month server-side and embedded as the sidecar. -
view
Which view to render; v1 supportsCalendarDef.CalendarView.MONTHonly. Defaults toMONTH. -
weekStart
First column of the week grid; defaults toCalendarDef.WeekStart.SUNDAY. -
initialMonth
Optional 1-based initial month (1..12); paired withinitialYear. -
initialYear
Optional initial year; paired withinitialMonth. -
maxPerDay
Optional max chips per day before "+N more"; defaults toDEFAULT_MAX_PER_DAY.
-
-
Constructor Details
-
CalendarDef
public CalendarDef()
-
-
Method Details
-
create
Creates an empty calendar definition.- Returns:
- A new
CalendarDef.
-
id
Sets the instance id.- Parameters:
value- The id. Must match[A-Za-z][A-Za-z0-9_-]*.- Returns:
- This object.
-
endpoint
Sets the per-month event GET template.- Parameters:
value- A same-origin path template containing{year}and{month}, ornull for seed-only.- Returns:
- This object.
-
categories
Sets the declared categories, in legend order.- Parameters:
value- The categories.- Returns:
- This object.
-
events
Sets the initial-month seed events.- Parameters:
value- The seed events.- Returns:
- This object.
-
view
Sets the view.- Parameters:
value- The view.- Returns:
- This object.
-
weekStart
Sets the week start column.- Parameters:
value- The week start.- Returns:
- This object.
-
initial
Sets the initial year and 1-based month together.- Parameters:
year- The initial year.month- The 1-based initial month (1..12).- Returns:
- This object.
-
maxPerDay
Sets the max chips per day before "+N more".- Parameters:
value- The cap; must be>= 1.- Returns:
- This object.
-
effectiveView
The effective view — the declaredvieworCalendarDef.CalendarView.MONTHwhen unset.- Returns:
- The effective view.
-
effectiveWeekStart
The effective week start — the declaredweekStartorCalendarDef.WeekStart.SUNDAYwhen unset.- Returns:
- The effective week start.
-
effectiveMaxPerDay
The effective chip cap — the declaredmaxPerDayorDEFAULT_MAX_PER_DAYwhen unset.- Returns:
- The effective chip cap.
-
effectiveLaneBudget
The per-week-row spanning-bar lane budget —effectiveMaxPerDay()clamped toMAX_LANES_PER_WEEK.Spanning bars occupy lanes counted against this budget;
maxPerDayitself continues to cap the non-spanning chips (single-day all-day plus timed) inside a day cell. The two caps are separate on purpose: a bar crossing a cell does not consume that cell's chip budget, and a hidden chip does not consume a lane.- Returns:
- The derived lane budget, at least 1 and at most
MAX_LANES_PER_WEEK.
-
wellFormedEvents
The seed events that are well-formed enough to paint — the malformed ones are dropped, exactly as a per-month GET handler drops them viaCalendarEvent.retainWellFormed(Collection).- Returns:
- A new mutable list of paintable seed events, in declaration order. Never
null .
-
validate
Description copied from interface:WidgetFail-closed bean validation. -
validate
Fail-closed bean validation against a resolved (year, month) window.When
initialYear/initialMonthare unset, the emitter resolves the effective window from the injected clock and passes it here so seed events are still checked against the month actually rendered.- Parameters:
effectiveYear- The year the initial month is rendered for, ornull to skip the off-month check.effectiveMonth- The 1-based month rendered, ornull to skip the off-month check.- Throws:
IllegalArgumentException- If this definition is not well-formed.
-