panel.removeAttribute("calendarView");
}
panel.setAttribute("calendar", calendar);
CalendarView calendarView = (CalendarView) panel.getAttribute("calendarView");
if (calendarView == null)
{
Date referenceDate = new Date();
if (panel.getAttribute("reference_day") != null)
referenceDate = (Date) panel.getAttribute("reference_day");
calendarView = new CalendarView(calendar, referenceDate, CalendarView.Period.MONTH, activeUser);
panel.setAttribute("calendarView", calendarView);
update = false;
}
if (form.isDoLastMonth())
{
if (log.isDebugEnabled())
log.debug("go to last month");
java.util.Calendar cal = GregorianCalendar.getInstance();
cal.setTime(calendarView.getReferenceDate());
if (cal.get(java.util.Calendar.MONTH) == java.util.Calendar.JANUARY)
cal.roll(java.util.Calendar.YEAR, -1);
cal.roll(java.util.Calendar.MONTH, -1);
calendarView.setReferenceDate(cal.getTime());
panel.setAttribute("reference_day", cal.getTime());
}
else if (form.isDoNextMonth())
{
if (log.isDebugEnabled())
log.debug("go to next month");
java.util.Calendar cal = GregorianCalendar.getInstance();
cal.setTime(calendarView.getReferenceDate());
if (cal.get(java.util.Calendar.MONTH) == java.util.Calendar.DECEMBER)
cal.roll(java.util.Calendar.YEAR, +1);
cal.roll(java.util.Calendar.MONTH, +1);
calendarView.setReferenceDate(cal.getTime());
panel.setAttribute("reference_day", cal.getTime());
}
else if (update)
{
calendarView.update();
}
if(!errors.isEmpty())
saveErrors(request, errors);
}