Using Vector
1 posts in topic
Flat View  Flat View

Posted By:   Shirley_Ho
Posted On:   Tuesday, December 10, 2002 07:17 PM

I have a database that contains the id, date, month, year and event. I would like to display the event in JSP codes according to the date, month and year in the format of an event calendar. There maybe some dates not included in the database. Therefore, there will be no display of event. First, I need to get the date, month, year and event from the database and place it into the vector. I assume that Vector is a key-value. Therefore, I need the key to be the date, month and year. Where else, the value to be the event. Note that if there are two or more events falls on the same date, month and year, it will have to be place together. So how do I go about it? I am using mysql for the database. Please help me.

Re: Using Vector

Posted By:   AlessandroA_Garbagnati  
Posted On:   Wednesday, December 11, 2002 01:09 AM


I would use a Map (probably a TreeMap) and use the date as the key. The value could be a simple List (ArrayList... eventually I would check performance later on) containing all the events for that day.

If you have the majority of single events per day, maybe you can consider to store the event and use the list only when there are more events.

Then you can create your calendar on the page and for each date you can check if there are events in the Map, and, when this happens, extract and do whatever you think is appropriate.

About | Sitemap | Contact