Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 1 | <html><body><pre>
|
| 2 | /*
|
| 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 | */
|
| 18 | package cal;
|
| 19 |
|
| 20 | import javax.servlet.http.*;
|
| 21 | import java.util.Hashtable;
|
| 22 |
|
| 23 | public class TableBean {
|
| 24 |
|
| 25 | Hashtable table;
|
| 26 | JspCalendar JspCal;
|
| 27 | Entries entries;
|
| 28 | String date;
|
| 29 | String name = null;
|
| 30 | String email = null;
|
| 31 | boolean processError = false;
|
| 32 |
|
| 33 | public TableBean () {
|
| 34 | this.table = new Hashtable (10);
|
| 35 | this.JspCal = new JspCalendar ();
|
| 36 | this.date = JspCal.getCurrentDate ();
|
| 37 | }
|
| 38 |
|
| 39 | public void setName (String nm) {
|
| 40 | this.name = nm;
|
| 41 | }
|
| 42 |
|
| 43 | public String getName () {
|
| 44 | return this.name;
|
| 45 | }
|
| 46 |
|
| 47 | public void setEmail (String mail) {
|
| 48 | this.email = mail;
|
| 49 | }
|
| 50 |
|
| 51 | public String getEmail () {
|
| 52 | return this.email;
|
| 53 | }
|
| 54 |
|
| 55 | public String getDate () {
|
| 56 | return this.date;
|
| 57 | }
|
| 58 |
|
| 59 | public Entries getEntries () {
|
| 60 | return this.entries;
|
| 61 | }
|
| 62 |
|
| 63 | public void processRequest (HttpServletRequest request) {
|
| 64 |
|
| 65 | // Get the name and e-mail.
|
| 66 | this.processError = false;
|
| 67 | if (name == null || name.equals("")) setName(request.getParameter ("name"));
|
| 68 | if (email == null || email.equals("")) setEmail(request.getParameter ("email"));
|
| 69 | if (name == null || email == null ||
|
| 70 | name.equals("") || email.equals("")) {
|
| 71 | this.processError = true;
|
| 72 | return;
|
| 73 | }
|
| 74 |
|
| 75 | // Get the date.
|
| 76 | String dateR = request.getParameter ("date");
|
| 77 | if (dateR == null) date = JspCal.getCurrentDate ();
|
| 78 | else if (dateR.equalsIgnoreCase("next")) date = JspCal.getNextDate ();
|
| 79 | else if (dateR.equalsIgnoreCase("prev")) date = JspCal.getPrevDate ();
|
| 80 |
|
| 81 | entries = (Entries) table.get (date);
|
| 82 | if (entries == null) {
|
| 83 | entries = new Entries ();
|
| 84 | table.put (date, entries);
|
| 85 | }
|
| 86 |
|
| 87 | // If time is provided add the event.
|
| 88 | String time = request.getParameter("time");
|
| 89 | if (time != null) entries.processRequest (request, time);
|
| 90 | }
|
| 91 |
|
| 92 | public boolean getProcessError () {
|
| 93 | return this.processError;
|
| 94 | }
|
| 95 | }
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 | </pre></body></html>
|