KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejosa > piggybank > presentation > enhydra > FoundationPO


1 /**
2  * Title: OpenUSS - Open Source University Support System
3  * My Piggy Bank Example
4  * Description: Enhydra Presentation Object
5  * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
6  * Company: University of Muenster, HTWK Leipzig
7  * @author B. Lofi Dewanto, T. Menzel
8  * @version 1.1
9  */

10 package net.sourceforge.ejosa.piggybank.presentation.enhydra;
11
12 import com.lutris.appserver.server.Enhydra;
13 import com.lutris.appserver.server.httpPresentation.*;
14 import com.lutris.appserver.server.user.User;
15
16 import com.lutris.logging.*;
17
18 import com.lutris.util.KeywordValueException;
19
20 //import com.lutris.xml.xmlc.*;
21
//import com.lutris.xml.xmlc.html.*;
22

23 import java.lang.Throwable JavaDoc;
24 import java.lang.reflect.*;
25
26 import java.text.*;
27
28 import java.util.*;
29
30 import org.openuss.presentation.enhydra.framework.*;
31
32 import org.openuss.utility.*;
33
34 import org.w3c.dom.*;
35 import org.w3c.dom.html.*;
36
37
38 /**
39  * The base presentation object for foundation components.
40  * This should be used to show a html file.
41  *
42  * @author B. Lofi Dewanto, T. Menzel
43  * @version 1.1
44  */

45 abstract public class FoundationPO extends BasePO implements HttpPresentation,
46                                                              BaseLayout {
47     protected static String JavaDoc MAIN_PAGE = "/Welcome.po";
48
49     /**
50      * Saved the session data.
51      */

52     protected FoundationSessionData mySessionData = null;
53
54     /**
55      * @return The saved comms objects
56      * to whichever subclass needs it
57      */

58     public FoundationSessionData getSessionData() {
59         return this.mySessionData;
60     }
61
62     /**
63      * Method to remove the all session data.
64      */

65     public void removeAllSessionData() {
66         this.getSessionData().getAndClearUserMessage();
67     }
68
69     /**
70      * Method to log the locale in to a session.
71      */

72     public void setLocale(Locale locale) throws FoundationPOException {
73         this.getSessionData().setLocale(locale);
74     }
75
76     /**
77      * Get the locale.
78      */

79     public Locale getLocale() {
80         return this.getSessionData().getLocale();
81     }
82
83     /**
84      * Superclass method override. For public means everybody can
85      * access this, otherwise he or she needs to be activated first.
86      */

87     public boolean isForPublicAccess() throws BasePOException {
88         // As a standard value, every pages are for the public
89
// access -> true
90
// You have to override this, if you want to change
91
// this behaviour
92
return true;
93     }
94
95     /**
96      * This implements the run method in HttpPresentation.
97      */

98     public void run(HttpPresentationComms comms) throws Exception JavaDoc {
99         // Initialize new or get the existing session data
100
initSessionData(comms);
101
102
103         // Check the security
104
checkSecurity();
105
106
107         // Handle the incoming event request
108
handleEvent(comms);
109     }
110
111     /**
112      * Method to get or create the AgSessionData object from the user session
113      * This object is saved in the EbrokerPresentation object
114      */

115     protected void initSessionData(HttpPresentationComms comms)
116                             throws FoundationPOException {
117         this.myComms = comms;
118
119         try {
120             Object JavaDoc obj = comms.sessionData.get(
121                                  FoundationSessionData.SESSION_KEY);
122
123             // If we found the session data, save it in a private data member
124
if (null != obj) {
125                 this.mySessionData = (FoundationSessionData) obj;
126             } else {
127                 // If no session data was found, create a new session data instance
128
this.mySessionData = new FoundationSessionData();
129                 comms.sessionData.set(FoundationSessionData.SESSION_KEY,
130                                       this.mySessionData);
131             }
132         } catch (KeywordValueException ex) {
133             writeDebugMsg("Problem getting session data from session: " +
134                           ex.getMessage());
135         }
136     }
137
138     /**
139      * Checks the session data for a User, if not there then redirects to the login
140      * page.
141      */

142     protected void checkForUserLogin() throws ClientPageRedirectException,
143                                               FoundationPOException {
144         // Do nothing
145
}
146
147     /**
148      * Checks the session data for a AccessList, if not there then redirects
149      * to the public login page, where the user can apply for the access.
150      */

151     protected void checkForAccessList() throws ClientPageRedirectException,
152                                                FoundationPOException {
153         // Do nothing
154
}
155
156     /**
157      * Check the security.
158      */

159     protected void checkSecurity() throws Exception JavaDoc {
160         // Check if the user needs to be logged in for this request
161
if (this.loggedInUserRequired()) {
162             checkForUserLogin();
163         }
164     }
165
166     /**
167      * This method has to be implemented. This write down the right-side
168      * information on the right side of the page. "Treebar".
169      */

170     public void showTreebar(Object JavaDoc page) throws BasePOException {
171         // Do nothing
172
}
173
174     /**
175      * This method has to be implemented. This updates the date on
176      * the top right.
177      */

178     public void showUpdatedDate(Object JavaDoc page) throws BasePOException {
179         // Do nothing
180
}
181
182     /**
183      * This method has to be implemented. This shows all the page
184      * layout. All layout methods should be called within
185      * this method.
186      */

187     public String JavaDoc showLayout(Object JavaDoc page) throws BasePOException {
188         // Return nothing
189
return null;
190     }
191 }
Popular Tags