Source Code Cross Referenced for BasePO.java in  » J2EE » Enhydra-Demos » org » openuss » presentation » enhydra » framework » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Demos » org.openuss.presentation.enhydra.framework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Title:        OpenUSS - Open Source University Support System
003:         * Description:  BasePO Presentation Object
004:         * Copyright:    Copyright (c) B. Lofi Dewanto
005:         * Company:      University of Muenster
006:         * @author  B. Lofi Dewanto
007:         * @version 1.0
008:         */package org.openuss.presentation.enhydra.framework;
009:
010:        import com.lutris.appserver.server.*;
011:        import com.lutris.appserver.server.httpPresentation.*;
012:        import com.lutris.appserver.server.user.User;
013:
014:        import com.lutris.logging.*;
015:
016:        import com.lutris.util.KeywordValueException;
017:
018:        //import com.lutris.xml.xmlc.*;
019:        //import com.lutris.xml.xmlc.html.*;
020:
021:        import java.lang.Throwable;
022:        import java.lang.reflect.*;
023:
024:        import java.util.*;
025:
026:        import org.w3c.dom.*;
027:        import org.w3c.dom.html.HTMLElement;
028:
029:        /**
030:         * The base presentation object for Enhydra.
031:         *
032:         * @author  B. Lofi Dewanto
033:         * @version 1.0
034:         */
035:        abstract public class BasePO {
036:            /**
037:             * An event must be called "event".
038:             */
039:            private static String EVENT = "event";
040:
041:            /**
042:             * Every methods have to use the handle in the
043:             * front of the method name, e.g.: handleLogin().
044:             */
045:            private static String STANDARD_METHOD_PREFIX = "handle";
046:
047:            /**
048:             * Saved HTML input and output context.
049:             */
050:            protected HttpPresentationComms myComms = null;
051:
052:            /**
053:             * This is the procedure that is called if there is no "event"
054:             * HTTP parameter found. It must be overriden by the subclass to
055:             * do default processing or error checking/handling.
056:             *
057:             * @return String The String representation of the HTML or (other format)
058:             * of the document to be displayed. This method would need to be changed
059:             * if you wanted to return binary data as well. It returns a String
060:             * for simplicity right now.
061:             */
062:            abstract public String handleDefault()
063:                    throws HttpPresentationException;
064:
065:            /**
066:             * This method should be implemented in the subclass so that it returns
067:             * true if this particular request requires the user to be logged
068:             * in, otherwise false.
069:             */
070:            abstract protected boolean loggedInUserRequired();
071:
072:            /**
073:             * This method should be implemented in the subclass, so that it returns
074:             * true if this particular request requires the user to apply first
075:             * for the access. For public means everybody can access this,
076:             * otherwise he or she needs to be activated first.
077:             */
078:            abstract protected boolean isForPublicAccess()
079:                    throws BasePOException;
080:
081:            /**
082:             * This method should be implemented in the subclass to change
083:             * the behaviour of the access list. Access list contents the current
084:             * student and the current enrollment. If the the current enrollment
085:             * is not for a public access, the student has to have an access list (accepted)
086:             * to get into this enrollment.
087:             */
088:            abstract protected void checkForAccessList()
089:                    throws ClientPageRedirectException, BasePOException;
090:
091:            /**
092:             * @return The saved comms objects
093:             * to whichever subclass needs it
094:             */
095:            public HttpPresentationComms getComms() {
096:                return this .myComms;
097:            }
098:
099:            /**
100:             * Method to call the proper method for the incoming event
101:             */
102:            public void handleEvent(HttpPresentationComms comms)
103:                    throws Exception {
104:                String event = comms.request.getParameter(EVENT);
105:                String returnHTML = null;
106:
107:                if ((event == null) || (event.length() == 0)) {
108:                    returnHTML = handleDefault();
109:                } else {
110:                    returnHTML = getPageContentForEvent(event);
111:                }
112:
113:                comms.response.writeHTML(returnHTML);
114:            }
115:
116:            /**
117:             * If an event parameter is defined then this invokes the method that
118:             * handles that event.
119:             */
120:            public String getPageContentForEvent(String event) throws Exception {
121:                try {
122:                    // Get the methodname
123:                    Method method = this .getClass().getMethod(
124:                            toMethodName(event), null);
125:
126:                    // Execute the run method
127:                    String thePage = (String) method.invoke(this , null);
128:
129:                    return thePage;
130:                } catch (InvocationTargetException ex) {
131:                    // Rethrow the originating exception if as it should be propagated as is
132:                    // It could be a page redirect exception, etc.
133:                    if (ex.getTargetException() instanceof  Exception) {
134:                        throw (Exception) ex.getTargetException();
135:                    } else if (ex.getTargetException() instanceof  Error) {
136:                        throw (Error) ex.getTargetException();
137:                    } else {
138:                        throw ex;
139:                    }
140:                } catch (NoSuchMethodException ex) {
141:                    // The method to handle the event does not exist.
142:                    throw new BasePOException(
143:                            "No event handler found for event: " + event, ex);
144:                } catch (IllegalAccessException ex) {
145:                    // The method to handle the event does not exist.
146:                    throw new BasePOException(
147:                            "Illegal access to event handler (is it public?): "
148:                                    + event, ex);
149:                }
150:            }
151:
152:            /**
153:             * This sets the first letter of the event parameter value in order
154:             * to adhere to Java method naming conventions.
155:             *
156:             * @param String event the incoming name of the event
157:             * @return String the properly capitalized name
158:             */
159:            private String toMethodName(String event) {
160:                StringBuffer methodName = new StringBuffer(
161:                        STANDARD_METHOD_PREFIX);
162:                methodName.append(Character.toUpperCase(event.charAt(0)));
163:
164:                if (event.length() > 1) {
165:                    methodName.append(event.substring(1));
166:                }
167:
168:                return methodName.toString();
169:            }
170:
171:            /**
172:             * Returns the application object associated with the
173:             * current request.
174:             *
175:             * @return the ebroker application object.
176:             */
177:            public StandardApplication getApplication() {
178:                return (StandardApplication) Enhydra.getApplication();
179:            }
180:
181:            /**
182:             * Method to write a debugging message to the debug log
183:             * channel when the DEBUG flag is turned on
184:             *
185:             * @param msg The message to write to the DEBUG log channel
186:             */
187:            public static void writeDebugMsg(String msg) {
188:                Enhydra.getLogChannel().write(Logger.DEBUG, msg);
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.