blob: 78c0e7f41e16c8abe259f721f5cb69e95ce1788a [file] [log] [blame]
Hongqing Liufd5ee812014-05-10 16:32:51 +08001<html><body><pre>
2/*
刘洪青6266f992017-05-15 21:21:03 +08003 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
Hongqing Liufd5ee812014-05-10 16:32:51 +080018package cal;
19
Hongqing Liufd5ee812014-05-10 16:32:51 +080020import java.util.Hashtable;
21
刘洪青6266f992017-05-15 21:21:03 +080022import javax.servlet.http.HttpServletRequest;
23
Hongqing Liufd5ee812014-05-10 16:32:51 +080024public class TableBean {
25
刘洪青6266f992017-05-15 21:21:03 +080026 Hashtable&lt;String, Entries> table;
27 JspCalendar JspCal;
28 Entries entries;
29 String date;
30 String name = null;
31 String email = null;
32 boolean processError = false;
Hongqing Liufd5ee812014-05-10 16:32:51 +080033
刘洪青6266f992017-05-15 21:21:03 +080034 public TableBean() {
35 this.table = new Hashtable&lt;String, Entries>(10);
36 this.JspCal = new JspCalendar();
37 this.date = JspCal.getCurrentDate();
Hongqing Liufd5ee812014-05-10 16:32:51 +080038 }
39
刘洪青6266f992017-05-15 21:21:03 +080040 public void setName(String nm) {
41 this.name = nm;
Hongqing Liufd5ee812014-05-10 16:32:51 +080042 }
43
刘洪青6266f992017-05-15 21:21:03 +080044 public String getName() {
45 return this.name;
46 }
Hongqing Liufd5ee812014-05-10 16:32:51 +080047
刘洪青6266f992017-05-15 21:21:03 +080048 public void setEmail(String mail) {
49 this.email = mail;
50 }
51
52 public String getEmail() {
53 return this.email;
54 }
55
56 public String getDate() {
57 return this.date;
58 }
59
60 public Entries getEntries() {
61 return this.entries;
62 }
63
64 public void processRequest(HttpServletRequest request) {
65
66 // Get the name and e-mail.
67 this.processError = false;
68 if (name == null || name.equals(""))
69 setName(request.getParameter("name"));
70 if (email == null || email.equals(""))
71 setEmail(request.getParameter("email"));
72 if (name == null || email == null || name.equals("")
73 || email.equals("")) {
74 this.processError = true;
75 return;
76 }
77
78 // Get the date.
79 String dateR = request.getParameter("date");
80 if (dateR == null)
81 date = JspCal.getCurrentDate();
82 else if (dateR.equalsIgnoreCase("next"))
83 date = JspCal.getNextDate();
84 else if (dateR.equalsIgnoreCase("prev"))
85 date = JspCal.getPrevDate();
86
87 entries = table.get(date);
88 if (entries == null) {
89 entries = new Entries();
90 table.put(date, entries);
91 }
92
93 // If time is provided add the event.
94 String time = request.getParameter("time");
95 if (time != null)
96 entries.processRequest(request, time);
97 }
98
99 public boolean getProcessError() {
100 return this.processError;
101 }
Hongqing Liufd5ee812014-05-10 16:32:51 +0800102}
Hongqing Liufd5ee812014-05-10 16:32:51 +0800103</pre></body></html>