001: /**
002: * Title: OpenUSS - Open Source University Support System
003: * My Piggy Bank Example
004: * Description: Enhydra Presentation Object
005: * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
006: * Company: University of Muenster, HTWK Leipzig
007: * @author B. Lofi Dewanto, T. Menzel
008: * @version 1.1
009: */package net.sourceforge.ejosa.piggybank.presentation.enhydra;
010:
011: import com.lutris.appserver.server.Enhydra;
012: import com.lutris.appserver.server.httpPresentation.*;
013: import com.lutris.appserver.server.user.User;
014:
015: import com.lutris.logging.*;
016:
017: import com.lutris.util.KeywordValueException;
018:
019: //import com.lutris.xml.xmlc.*;
020: //import com.lutris.xml.xmlc.html.*;
021:
022: import java.lang.Throwable;
023: import java.lang.reflect.*;
024:
025: import java.text.*;
026:
027: import java.util.*;
028:
029: import org.openuss.presentation.enhydra.framework.*;
030:
031: import org.openuss.utility.*;
032:
033: import org.w3c.dom.*;
034: import org.w3c.dom.html.*;
035:
036: /**
037: * The base presentation object for foundation components.
038: * This should be used to show a html file.
039: *
040: * @author B. Lofi Dewanto, T. Menzel
041: * @version 1.1
042: */
043: abstract public class FoundationPO extends BasePO implements
044: HttpPresentation, BaseLayout {
045: protected static String MAIN_PAGE = "/Welcome.po";
046:
047: /**
048: * Saved the session data.
049: */
050: protected FoundationSessionData mySessionData = null;
051:
052: /**
053: * @return The saved comms objects
054: * to whichever subclass needs it
055: */
056: public FoundationSessionData getSessionData() {
057: return this .mySessionData;
058: }
059:
060: /**
061: * Method to remove the all session data.
062: */
063: public void removeAllSessionData() {
064: this .getSessionData().getAndClearUserMessage();
065: }
066:
067: /**
068: * Method to log the locale in to a session.
069: */
070: public void setLocale(Locale locale) throws FoundationPOException {
071: this .getSessionData().setLocale(locale);
072: }
073:
074: /**
075: * Get the locale.
076: */
077: public Locale getLocale() {
078: return this .getSessionData().getLocale();
079: }
080:
081: /**
082: * Superclass method override. For public means everybody can
083: * access this, otherwise he or she needs to be activated first.
084: */
085: public boolean isForPublicAccess() throws BasePOException {
086: // As a standard value, every pages are for the public
087: // access -> true
088: // You have to override this, if you want to change
089: // this behaviour
090: return true;
091: }
092:
093: /**
094: * This implements the run method in HttpPresentation.
095: */
096: public void run(HttpPresentationComms comms) throws Exception {
097: // Initialize new or get the existing session data
098: initSessionData(comms);
099:
100: // Check the security
101: checkSecurity();
102:
103: // Handle the incoming event request
104: handleEvent(comms);
105: }
106:
107: /**
108: * Method to get or create the AgSessionData object from the user session
109: * This object is saved in the EbrokerPresentation object
110: */
111: protected void initSessionData(HttpPresentationComms comms)
112: throws FoundationPOException {
113: this .myComms = comms;
114:
115: try {
116: Object obj = comms.sessionData
117: .get(FoundationSessionData.SESSION_KEY);
118:
119: // If we found the session data, save it in a private data member
120: if (null != obj) {
121: this .mySessionData = (FoundationSessionData) obj;
122: } else {
123: // If no session data was found, create a new session data instance
124: this .mySessionData = new FoundationSessionData();
125: comms.sessionData.set(
126: FoundationSessionData.SESSION_KEY,
127: this .mySessionData);
128: }
129: } catch (KeywordValueException ex) {
130: writeDebugMsg("Problem getting session data from session: "
131: + ex.getMessage());
132: }
133: }
134:
135: /**
136: * Checks the session data for a User, if not there then redirects to the login
137: * page.
138: */
139: protected void checkForUserLogin()
140: throws ClientPageRedirectException, FoundationPOException {
141: // Do nothing
142: }
143:
144: /**
145: * Checks the session data for a AccessList, if not there then redirects
146: * to the public login page, where the user can apply for the access.
147: */
148: protected void checkForAccessList()
149: throws ClientPageRedirectException, FoundationPOException {
150: // Do nothing
151: }
152:
153: /**
154: * Check the security.
155: */
156: protected void checkSecurity() throws Exception {
157: // Check if the user needs to be logged in for this request
158: if (this .loggedInUserRequired()) {
159: checkForUserLogin();
160: }
161: }
162:
163: /**
164: * This method has to be implemented. This write down the right-side
165: * information on the right side of the page. "Treebar".
166: */
167: public void showTreebar(Object page) throws BasePOException {
168: // Do nothing
169: }
170:
171: /**
172: * This method has to be implemented. This updates the date on
173: * the top right.
174: */
175: public void showUpdatedDate(Object page) throws BasePOException {
176: // Do nothing
177: }
178:
179: /**
180: * This method has to be implemented. This shows all the page
181: * layout. All layout methods should be called within
182: * this method.
183: */
184: public String showLayout(Object page) throws BasePOException {
185: // Return nothing
186: return null;
187: }
188: }
|