001: /*
002: * Copyright 2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package cal;
017:
018: import java.beans.*;
019: import javax.servlet.http.*;
020: import javax.servlet.*;
021: import java.util.Hashtable;
022:
023: public class TableBean {
024:
025: Hashtable table;
026: JspCalendar JspCal;
027: Entries entries;
028: String date;
029: String name = null;
030: String email = null;
031: boolean processError = false;
032:
033: public TableBean() {
034: this .table = new Hashtable(10);
035: this .JspCal = new JspCalendar();
036: this .date = JspCal.getCurrentDate();
037: }
038:
039: public void setName(String nm) {
040: this .name = nm;
041: }
042:
043: public String getName() {
044: return this .name;
045: }
046:
047: public void setEmail(String mail) {
048: this .email = mail;
049: }
050:
051: public String getEmail() {
052: return this .email;
053: }
054:
055: public String getDate() {
056: return this .date;
057: }
058:
059: public Entries getEntries() {
060: return this .entries;
061: }
062:
063: public void processRequest(HttpServletRequest request) {
064:
065: // Get the name and e-mail.
066: this .processError = false;
067: if (name == null || name.equals(""))
068: setName(request.getParameter("name"));
069: if (email == null || email.equals(""))
070: setEmail(request.getParameter("email"));
071: if (name == null || email == null || name.equals("")
072: || email.equals("")) {
073: this .processError = true;
074: return;
075: }
076:
077: // Get the date.
078: String dateR = request.getParameter("date");
079: if (dateR == null)
080: date = JspCal.getCurrentDate();
081: else if (dateR.equalsIgnoreCase("next"))
082: date = JspCal.getNextDate();
083: else if (dateR.equalsIgnoreCase("prev"))
084: date = JspCal.getPrevDate();
085:
086: entries = (Entries) table.get(date);
087: if (entries == null) {
088: entries = new Entries();
089: table.put(date, entries);
090: }
091:
092: // If time is provided add the event.
093: String time = request.getParameter("time");
094: if (time != null)
095: entries.processRequest(request, time);
096: }
097:
098: public boolean getProcessError() {
099: return this.processError;
100: }
101: }
|