Problems with viewing calendar
This is it (the formatter seems to get a bit confused by the html, especially the "p" tags):
AddToArray findEvent = new AddToArray(publicArraylist);
String tableCells(Calendar thisMonth)
{
publicArraylist.add(new String[] {"Meet Nicolas!", "2006.03.15", "20:30", "This is the first record in the arraylist. It can't be empty (NullPointerException)."});
StringBuffer returnValue = new StringBuffer();
//** record the current value of the field Calendar.MONTH
int iThisMonth = thisMonth.get(Calendar.MONTH);
Calendar today = Calendar.getInstance(); //used to highlight today's date cell in the calendar
Calendar endOfMonth = (Calendar)thisMonth.clone();
endOfMonth.set(Calendar.DATE,endOfMonth.getActualMaximum(Calendar.DATE));
endOfMonth.add(Calendar.DATE,7-endOfMonth.get(Calendar.DAY_OF_WEEK));
//** set calendar to first day of the first week (may move back 1 month)
thisMonth.add(Calendar.DATE,1-thisMonth.get(Calendar.DAY_OF_WEEK));
do
{
returnValue.append("<TR BORDER=1 VALIGN=TOP>");
for (int i=0; i < 7; i++)
{
returnValue.append("<TD HEIGHT=100 WIDTH=85");
if (thisMonth.get(Calendar.MONTH) != iThisMonth) returnValue.append(" BGCOLOR=#e0e0e0"); // dark background for out-of-month days
else if (dfDateField.format(thisMonth.getTime()).equals(dfDateField.format(today.getTime()))) returnValue.append(" BGCOLOR=#ffff00"); // yellow background for today's date
else returnValue.append(" BGCOLOR=#ffffff"); // default white background
returnValue.append(">" +
dfDateField.format(thisMonth.getTime()) + ">" +
"<FONT FACE=VERDANA COLOR=#000000 SIZE=2>" + dfDayOfMonth.format(thisMonth.getTime()) + "");
//### SEARCH FOR EVENTS OF THIS DAY AND THEN DISPLAY THEM ###
returnValue.append("<p>");
String[] theEvent = new String[3];
theEvent = findEvent.getEvent(thisMonth.getTime());
if (theEvent[2] != null)
{
returnValue.append(theEvent[2] + ":\n");
returnValue.append("<FONT COLOR=RED>");
returnValue.append(theEvent[0]);
returnValue.append("</FONT>");
}
returnValue.append("</p>");
returnValue.append("</FONT>");
returnValue.append("</TD>");
thisMonth.add(Calendar.DATE,1);
}
returnValue.append("</TR>");
}
while(thisMonth.getTime().before(endOfMonth.getTime()));
//** restore date to first of this month:
thisMonth.add(Calendar.MONTH,-1);
thisMonth.set(Calendar.DATE,1);
return returnValue.toString();
}
And here's the problem:
The beginning of the calendar won't show! Everything from and with the row which includes today. For example, if today is in the very beginning of the month, all of the calendar is shown. If today is one of the last days of the month, only the last row is shown. It is extremely frustrating, and I just can't seem to find the solution. I'd really appreciate of someone would like to take a look at it. Don't hesitate to ask questions about the coding, I'll be glad to try to explain anything (even I think the code is a mess).
Here are two screenshots to illustrate my problem. As you might notice, the output is slightly different than shown in the code. It no longer outputs "no events today" if there are no events to display. Also, there seems to have been a problem with the naming of the files. Naturally, the file called "w problems" is the one that shows the calendar without problems, and vice versa.
http://www.recap13.com/ANNAT/08_calendar_show_events_w_problems.jpg
http://www.recap13.com/ANNAT/09_calendar_show_events_wout_problems.jpg
Thanks in advance!

