001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package cal; 018 019 import java.util.Hashtable; 020 021 import javax.servlet.http.HttpServletRequest; 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("")) setName(request.getParameter("name")); 068 if (email == null || email.equals("")) setEmail(request.getParameter("email")); 069 if (name == null || email == null || 070 name.equals("") || email.equals("")) { 071 this.processError = true; 072 return; 073 } 074 075 // Get the date. 076 String dateR = request.getParameter("date"); 077 if (dateR == null) date = JspCal.getCurrentDate(); 078 else if (dateR.equalsIgnoreCase("next")) date = JspCal.getNextDate(); 079 else if (dateR.equalsIgnoreCase("prev")) date = JspCal.getPrevDate(); 080 081 entries = (Entries) table.get(date); 082 if (entries == null) { 083 entries = new Entries(); 084 table.put(date, entries); 085 } 086 087 // If time is provided add the event. 088 String time = request.getParameter("time"); 089 if (time != null) entries.processRequest(request, time); 090 } 091 092 public boolean getProcessError() { 093 return this.processError; 094 } 095 } 096 097 098 099 100 101