next.append("&selectedMonthName=" + nextWeekMonth + "&selectedYear=" + nextWeekYear + "');");
calendarNavBarList.add(new DDNameValue("Previous", previous.toString()));
calendarNavBarList.add(new DDNameValue("Current Week", current.toString()));
calendarNavBarList.add(new DDNameValue("Next", next.toString()));
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd");
String dailyGo = "c_goTo('/calendar.do?Type=DAILY";
if (currentDay != 0 && currentMonth >= 0 && currentYear != 0) {
Calendar headerCalendarWeek = Calendar.getInstance();
headerCalendarWeek.set(currentYear, currentMonth, currentDay);
int dayOfWeek = headerCalendarWeek.get(Calendar.DAY_OF_WEEK);
// Subtracting it with 2 coz in the Calendar Starting Day is Monday.
int offset = dayOfWeek - 2;
if (offset < 0) {
int daysInWeek = 7;
// if we are before the current day of the week, we need to fall all
// the way back to the previous beginning of the week. calculating our
// offset in this way will give us the right num of days to the
// previous start. this makes it easy to just add it to the
// currentDate.
offset = daysInWeek + offset;
}
int currentDate = headerCalendarWeek.get(Calendar.DATE);
headerCalendarWeek.set(Calendar.DATE, currentDate - offset);
int headerDayOfMonth = headerCalendarWeek.get(Calendar.DATE);
int headerMonthOfYear = headerCalendarWeek.get(Calendar.MONTH);
int headerYear = headerCalendarWeek.get(Calendar.YEAR);
try {
// This is used in the columnar weekly view for calculating the
// date to be filled in when you click on a empty cell.
calendarNavBarMap.put("startDayOfWeek", new Integer(headerDayOfMonth));
} catch (NumberFormatException nfe) {
logger.info("[setCalendarNavBar]: The offset for the clickable weekly view boxes will probably be broken.");
calendarNavBarMap.put("startDayOfWeek", new Integer(0));
}
String dateString = headerYear + ",'" + getCalenderMonthName(headerMonthOfYear) + "'," + headerDayOfMonth;
String headerDate = formatter.format(headerCalendarWeek.getTime());
String dailyDate = "&selectedDay=" + headerDayOfMonth + "&selectedMonthName=" + getCalenderMonthName(headerMonthOfYear) + "&selectedYear="
+ headerYear;
String action = "ScheduleActivity(" + dateString + ",'','');";
dateList.put(String.valueOf(0), action);
headerLinkList.put(String.valueOf(0), dailyGo + dailyDate + "');");
headerList.put(String.valueOf(0), headerDate);
int count = 1;
for (int i = 0; i < 6; i++) {
headerCalendarWeek.add(Calendar.DATE, 1);
headerDayOfMonth = headerCalendarWeek.get(Calendar.DAY_OF_MONTH);
headerMonthOfYear = headerCalendarWeek.get(Calendar.MONTH);
headerYear = headerCalendarWeek.get(Calendar.YEAR);
dateString = headerYear + ",'" + getCalenderMonthName(headerMonthOfYear) + "'," + headerDayOfMonth;
action = "ScheduleActivity(" + dateString + ",'','');";
dateList.put(String.valueOf(count), action);
headerDate = formatter.format(headerCalendarWeek.getTime());
headerList.put(String.valueOf(count), headerDate);
dailyDate = "&selectedDay=" + headerDayOfMonth + "&selectedMonthName=" + getCalenderMonthName(headerMonthOfYear) + "&selectedYear="
+ headerYear;
headerLinkList.put(String.valueOf(count), dailyGo + dailyDate + "');");
count++;