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 javax.servlet.http.*; 020 import java.util.Hashtable; 021 022 public class TableBean { 023 024 Hashtable table; 025 JspCalendar JspCal; 026 Entries entries; 027 String date; 028 String name = null; 029 String email = null; 030 boolean processError = false; 031 032 public TableBean () { 033 this.table = new Hashtable (10); 034 this.JspCal = new JspCalendar (); 035 this.date = JspCal.getCurrentDate (); 036 } 037 038 public void setName (String nm) { 039 this.name = nm; 040 } 041 042 public String getName () { 043 return this.name; 044 } 045 046 public void setEmail (String mail) { 047 this.email = mail; 048 } 049 050 public String getEmail () { 051 return this.email; 052 } 053 054 public String getDate () { 055 return this.date; 056 } 057 058 public Entries getEntries () { 059 return this.entries; 060 } 061 062 public void processRequest (HttpServletRequest request) { 063 064 // Get the name and e-mail. 065 this.processError = false; 066 if (name == null || name.equals("")) setName(request.getParameter ("name")); 067 if (email == null || email.equals("")) setEmail(request.getParameter ("email")); 068 if (name == null || email == null || 069 name.equals("") || email.equals("")) { 070 this.processError = true; 071 return; 072 } 073 074 // Get the date. 075 String dateR = request.getParameter ("date"); 076 if (dateR == null) date = JspCal.getCurrentDate (); 077 else if (dateR.equalsIgnoreCase("next")) date = JspCal.getNextDate (); 078 else if (dateR.equalsIgnoreCase("prev")) date = JspCal.getPrevDate (); 079 080 entries = (Entries) table.get (date); 081 if (entries == null) { 082 entries = new Entries (); 083 table.put (date, entries); 084 } 085 086 // If time is provided add the event. 087 String time = request.getParameter("time"); 088 if (time != null) entries.processRequest (request, time); 089 } 090 091 public boolean getProcessError () { 092 return this.processError; 093 } 094 } 095 096 097 098 099 100