source: nutchez-0.1/tomcat/webapps/examples/WEB-INF/classes/cal/TableBean.java @ 66

Last change on this file since 66 was 66, checked in by waue, 15 years ago

NutchEz - an easy way to nutch

File size: 2.6 KB
Line 
1/*
2* Licensed to the Apache Software Foundation (ASF) under one or more
3* contributor license agreements.  See the NOTICE file distributed with
4* this work for additional information regarding copyright ownership.
5* The ASF licenses this file to You under the Apache License, Version 2.0
6* (the "License"); you may not use this file except in compliance with
7* the License.  You may obtain a copy of the License at
8*
9*     http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*/
17package cal;
18
19import javax.servlet.http.*;
20import java.util.Hashtable;
21
22public class TableBean {
23
24  Hashtable table;
25  JspCalendar JspCal;
26  Entries entries;
27  String date;
28  String name = null;
29  String email = null;
30  boolean processError = false;
31
32  public TableBean () {
33    this.table = new Hashtable (10);
34    this.JspCal = new JspCalendar ();
35    this.date = JspCal.getCurrentDate ();
36  }
37
38  public void setName (String nm) {
39    this.name = nm;
40  }
41
42  public String getName () {
43    return this.name;
44  }
45 
46  public void setEmail (String mail) {
47    this.email = mail;
48  }
49
50  public String getEmail () {
51    return this.email;
52  }
53
54  public String getDate () {
55    return this.date;
56  }
57
58  public Entries getEntries () {
59    return this.entries;
60  }
61
62  public void processRequest (HttpServletRequest request) {
63
64    // Get the name and e-mail.
65    this.processError = false;
66    if (name == null || name.equals("")) setName(request.getParameter ("name")); 
67    if (email == null || email.equals("")) setEmail(request.getParameter ("email"));
68    if (name == null || email == null ||
69    name.equals("") || email.equals("")) {
70      this.processError = true;
71      return;
72    }
73
74    // Get the date.
75    String dateR = request.getParameter ("date");
76    if (dateR == null) date = JspCal.getCurrentDate ();
77    else if (dateR.equalsIgnoreCase("next")) date = JspCal.getNextDate ();
78    else if (dateR.equalsIgnoreCase("prev")) date = JspCal.getPrevDate ();
79
80    entries = (Entries) table.get (date);
81    if (entries == null) {
82      entries = new Entries ();
83      table.put (date, entries);
84    }
85
86    // If time is provided add the event.
87  String time = request.getParameter("time");
88    if (time != null) entries.processRequest (request, time);
89  }
90
91  public boolean getProcessError () {
92    return this.processError;
93  }
94}
95
96
97
98
99
100
Note: See TracBrowser for help on using the repository browser.