}
request.setAttribute("Type", type);
}
// Default start and end time. are today, 0:00 through tomorrow 0:00
GregorianCalendar startTimeUser = new GregorianCalendar(tz);
// Set the default starting day of week to Monday.
// TODO: make a preference for the starting day of the week, and use it
// here.
startTimeUser.setFirstDayOfWeek(Calendar.MONDAY);
startTimeUser.setTimeInMillis(System.currentTimeMillis());
int currentDay = startTimeUser.get(Calendar.DATE);
int currentMonth = startTimeUser.get(Calendar.MONTH);
int currentYear = startTimeUser.get(Calendar.YEAR);
GregorianCalendar currentDateCalendar = new GregorianCalendar(currentYear, currentMonth, currentDay);
request.setAttribute("currentDate", currentDateCalendar);
String monthName = CalendarUtil.getCalenderMonthName(currentMonth);
calendardyna.set("currentDate", monthName + " " + currentDay + ", " + currentYear);
calendardyna.set("currentDay", new Integer(currentDay));
calendardyna.set("currentMonth", new Integer(currentMonth));
calendardyna.set("currentMonthName", monthName);
calendardyna.set("currentYear", new Integer(currentYear));
// the sDay, sMonth and sYear is the date set by the navigation or
// selection
String selectedDay = request.getParameter("selectedDay");
String selectedMonthName = request.getParameter("selectedMonthName");
String selectedYear = request.getParameter("selectedYear");
// Check to see is session exists, if not set to default
if (session.getAttribute("selectedDay") == null) {
session.setAttribute("selectedDay", (new Integer(currentDay)).toString());
}
if (session.getAttribute("selectedMonthName") == null) {
session.setAttribute("selectedMonthName", monthName);
}
if (session.getAttribute("selectedYear") == null) {
session.setAttribute("selectedYear", (new Integer(currentYear)).toString());
}
// If request passes in selected day, set session to new value
if (selectedDay != null) {
session.setAttribute("selectedDay", selectedDay);
}
if (selectedMonthName != null) {
session.setAttribute("selectedMonthName", selectedMonthName);
}
if (selectedYear != null) {
session.setAttribute("selectedYear", selectedYear);
}
// set local objects to value stored in session
selectedDay = (String) session.getAttribute("selectedDay");
selectedMonthName = (String) session.getAttribute("selectedMonthName");
selectedYear = (String) session.getAttribute("selectedYear");
int day = Integer.parseInt(selectedDay);
int month = (selectedMonthName == null) ? currentMonth : CalendarUtil.getCalendarMonth(selectedMonthName);
int year = (selectedYear == null) ? currentYear : Integer.parseInt(selectedYear);
if (selectedMonthName == null) {
selectedMonthName = CalendarUtil.getCalenderMonthName(currentMonth);
}
GregorianCalendar selectedDate = new GregorianCalendar(year, month, 1);
request.setAttribute("selectedDate", selectedDate);
request.setAttribute("showWeeklyColumn", new Boolean(true));
calendardyna.set("selectedDate", selectedMonthName + " " + day + ", " + year);
calendardyna.set("selectedDay", String.valueOf(day));
calendardyna.set("selectedYear", String.valueOf(year));
calendardyna.set("selectedMonthName", selectedMonthName);
// Selected Day midnight
startTimeUser.clear();
startTimeUser.set(year, month, day);
HashMap calendarNavBar = CalendarUtil.setCalendarNavBar(year, month, day, type);
calendardyna.set("calendarNavBar", calendarNavBar.get("calendarNavBar"));
calendardyna.set("headerList", calendarNavBar.get("headerList"));
calendardyna.set("headerLinkList", calendarNavBar.get("headerLinkList"));
calendardyna.set("dateList", calendarNavBar.get("dateList"));
calendardyna.set("startDayOfWeek", calendarNavBar.get("startDayOfWeek"));
GregorianCalendar endTimeUser = new GregorianCalendar(tz);
endTimeUser.setTime(startTimeUser.getTime());
endTimeUser.add(Calendar.DATE, 1); // Selected Day+1 midnight
if (type.equals("DAILY")) {
// Daily view, set the timespan to 15, 30 or 60
// minutes per table row, based on the dropdown.
if (request.getParameter("timespan") != null) {
timespan = Integer.parseInt(request.getParameter("timespan"));
}
startTimeUser.set(year, month, day, 0, 0);
endTimeUser.setTime(startTimeUser.getTime());
endTimeUser.add(Calendar.DATE, 1);
Final_Forward = ".view.calendar.dailylist";
} else if (type.equals("MONTHLY")) {
// Monthly View
// That means timespan is 1440 for some reason. I guess
// the math works out that way .. ?!
timespan = 1440;
// start is first of the month
startTimeUser.set(year, month, 1, 0, 0);
// end is first of NEXT month
endTimeUser.setTime(startTimeUser.getTime());
endTimeUser.add(Calendar.MONTH, 1);
Final_Forward = ".view.calendar.monthlylist";
} else if (type.equals("WEEKLY")) {
// Weekly (NON-columnar) view
// That means timespan is 1440 for some reason. I guess
// the math works out that way .. ?!
timespan = 1440;
// in the non-columnar view we always start the week on Monday.
startTimeUser.setFirstDayOfWeek(Calendar.MONDAY);
startTimeUser = CalendarUtil.setToStartOfWeek(startTimeUser);
endTimeUser.setTime(startTimeUser.getTime());
endTimeUser.add(Calendar.DAY_OF_MONTH, 7);
Final_Forward = ".view.calendar.weeklylist";
} else if (type.equals("WEEKLYCOLUMNS")) {
timespan = 60;
startTimeUser.set(Calendar.DAY_OF_WEEK, startTimeUser.getFirstDayOfWeek());
startTimeUser = CalendarUtil.setToStartOfWeek(startTimeUser);
endTimeUser.setTime(startTimeUser.getTime());
endTimeUser.add(Calendar.DAY_OF_MONTH, 7);
Final_Forward = ".view.calendar.weeklycolumnarlist";
} else if (type.equals("YEARLY")) {
Final_Forward = ".view.calendar.yearlylist";
return (mapping.findForward(Final_Forward));
}