Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 1 | <html><body><pre>
|
| 2 | /*
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 3 | * 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 Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 18 | package cal;
|
| 19 |
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 20 | import java.util.Hashtable;
|
| 21 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 22 | import javax.servlet.http.HttpServletRequest;
|
| 23 |
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 24 | public class TableBean {
|
| 25 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 26 | Hashtable<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 Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 33 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 34 | public TableBean() {
|
| 35 | this.table = new Hashtable<String, Entries>(10);
|
| 36 | this.JspCal = new JspCalendar();
|
| 37 | this.date = JspCal.getCurrentDate();
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 38 | }
|
| 39 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 40 | public void setName(String nm) {
|
| 41 | this.name = nm;
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 42 | }
|
| 43 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 44 | public String getName() {
|
| 45 | return this.name;
|
| 46 | }
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 47 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 48 | 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 Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 102 | }
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 103 | </pre></body></html>
|