/Users/lyon/j4p/src/net/server/cal/TableBean.java

1    /* 
2     * 
3     * Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. 
4     * 
5     * This software is the confidential and proprietary information of Sun 
6     * Microsystems, Inc. ("Confidential Information").  You shall not 
7     * disclose such Confidential Information and shall use it only in 
8     * accordance with the terms of the license agreement you entered into 
9     * with Sun. 
10    * 
11    * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE 
12    * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
13    * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
14    * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES 
15    * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 
16    * THIS SOFTWARE OR ITS DERIVATIVES. 
17    * 
18    * @author Mandar Raje 
19    */ 
20    
21   package net.server.cal; 
22    
23   import javax.servlet.http.HttpServletRequest; 
24   import java.util.Hashtable; 
25    
26   public class TableBean { 
27    
28       Hashtable table; 
29       JspCalendar JspCal; 
30       Entries entries; 
31       String date; 
32       String name = null; 
33       String email = null; 
34       boolean processError = false; 
35    
36       public TableBean() { 
37           this.table = new Hashtable(10); 
38           this.JspCal = new JspCalendar(); 
39           this.date = JspCal.getCurrentDate(); 
40       } 
41    
42       public void setName(String nm) { 
43           this.name = nm; 
44       } 
45    
46       public String getName() { 
47           return this.name; 
48       } 
49    
50       public void setEmail(String mail) { 
51           this.email = mail; 
52       } 
53    
54       public String getEmail() { 
55           return this.email; 
56       } 
57    
58       public String getDate() { 
59           return this.date; 
60       } 
61    
62       public Entries getEntries() { 
63           return this.entries; 
64       } 
65    
66       public void processRequest(HttpServletRequest request) { 
67    
68           // Get the name and e-mail. 
69           this.processError = false; 
70           if (name == null || name.equals("")) setName(request.getParameter("name")); 
71           if (email == null || email.equals("")) setEmail(request.getParameter("email")); 
72           if (name == null || email == null || 
73                   name.equals("") || 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")) date = JspCal.getPrevDate(); 
85    
86           entries = (Entries) table.get(date); 
87           if (entries == null) { 
88               entries = new Entries(); 
89               table.put(date, entries); 
90           } 
91    
92           // If time is provided add the event. 
93           String time = request.getParameter("time"); 
94           if (time != null) entries.processRequest(request, time); 
95       } 
96    
97       public boolean getProcessError() { 
98           return this.processError; 
99       } 
100  } 
101   
102   
103   
104   
105   
106   
107