Class DefaultCalendarViewController
- java.lang.Object
-
- it.tidalwave.northernwind.frontend.ui.component.calendar.DefaultCalendarViewController
-
- All Implemented Interfaces:
CalendarViewController
,ViewController
public abstract class DefaultCalendarViewController extends java.lang.Object implements CalendarViewController
A default implementation of the
CalendarViewController
that is independent of the presentation technology. This class is capable to render a yearly calendar with items and related links.It accepts a single path parameter
year
with selects a given year; otherwise the current year is used.Supported properties of the
SiteNode
:P_ENTRIES
: a property with XML format that describes the entries;P_SELECTED_YEAR
: the year to render (optional, otherwise the current year is used);P_FIRST_YEAR
: the first available year;P_LAST_YEAR
: the last available year ;P_TITLE
: the page title (optional);P_COLUMNS
: the number of columns of the table to render (optional, defaults to 4).
The property
P_ENTRIES
must have the following structure:<?xml version="1.0" encoding="UTF-8"?> <calendar> <year id="2004"> <month id="jan"> <item name="Provence" type="major" link="/diary/2004/01/02/"/> <item name="Bocca di Magra" link="/diary/2004/01/24/"/> <item name="Maremma" link="/diary/2004/01/31/"/> </month> ... </year> ... </calendar>
Concrete implementations must provide one method for rendering the calendar:
#render(int, int, int, java.util.Map)
- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultCalendarViewController.Entry
-
Field Summary
Fields Modifier and Type Field Description protected RequestLocaleManager
requestLocaleManager
-
Fields inherited from interface it.tidalwave.northernwind.frontend.ui.component.calendar.CalendarViewController
P_COLUMNS, P_ENTRIES, P_FIRST_YEAR, P_LAST_YEAR, P_SELECTED_YEAR
-
-
Constructor Summary
Constructors Constructor Description DefaultCalendarViewController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
createYearLink(int year)
Creates a link for the current year.protected ResourceProperties
getViewProperties()
void
prepareRendering(RenderContext context)
Compute stuff here, to eventually fail fast.protected abstract void
render(java.util.Optional<java.lang.String> title, int year, int firstYear, int lastYear, java.util.SortedMap<java.lang.Integer,java.util.List<DefaultCalendarViewController.Entry>> byMonth, int columns)
Renders the diary.void
renderView(RenderContext context)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.tidalwave.northernwind.frontend.ui.ViewController
findVirtualSiteNodes, initialize
-
-
-
-
Field Detail
-
requestLocaleManager
@Nonnull protected final RequestLocaleManager requestLocaleManager
-
-
Method Detail
-
prepareRendering
public void prepareRendering(@Nonnull RenderContext context) throws HttpStatusException
Compute stuff here, to eventually fail fast.- Specified by:
prepareRendering
in interfaceViewController
- Throws:
HttpStatusException
-
renderView
public void renderView(@Nonnull RenderContext context)
- Specified by:
renderView
in interfaceViewController
-
render
protected abstract void render(@Nonnull java.util.Optional<java.lang.String> title, @Nonnegative int year, @Nonnegative int firstYear, @Nonnegative int lastYear, @Nonnull java.util.SortedMap<java.lang.Integer,java.util.List<DefaultCalendarViewController.Entry>> byMonth, int columns)
Renders the diary.- Parameters:
title
- a title for the page (optional)year
- the current yearfirstYear
- the first available yearlastYear
- the last available yearbyMonth
- a map of entries for the current year indexed by monthcolumns
- the number of columns of the table to render
-
getViewProperties
@Nonnull protected final ResourceProperties getViewProperties()
-
createYearLink
@Nonnull protected final java.lang.String createYearLink(int year)
Creates a link for the current year.- Parameters:
year
- the year- Returns:
- the link
-
-