1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package cal;
17
18 import java.beans.*;
19 import javax.servlet.http.*;
20 import javax.servlet.*;
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
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
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
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