Source Code Cross Referenced for MessageSupport.java in  » Web-Framework » calyxo » de » odysseus » calyxo » control » 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 » Web Framework » calyxo » de.odysseus.calyxo.control 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004, 2005, 2006 Odysseus Software GmbH
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package de.odysseus.calyxo.control;
017:
018:        import javax.servlet.http.HttpServletRequest;
019:        import javax.servlet.jsp.PageContext;
020:
021:        import de.odysseus.calyxo.base.Message;
022:        import de.odysseus.calyxo.base.Messages;
023:        import de.odysseus.calyxo.base.ModuleContext;
024:        import de.odysseus.calyxo.base.ModuleSupport;
025:
026:        /**
027:         * Messages support class.
028:         * <p/>
029:         * Actions may produce errors, warnings and infos during request processing.
030:         * Corresponding messages can be retreived from and saved to the current
031:         * request using this class.
032:         * <p/>
033:         * There are several convenience methods to save error, warning and info
034:         * messages without explicitely getting the messages.
035:         * <p/>
036:         * There's one instance per module.
037:         * Use one of the <code>getInstance()</code> methods to get it.
038:         * 
039:         * @author Christoph Beck
040:         */
041:        public abstract class MessageSupport {
042:
043:            /**
044:             * Module scope key where the message support instance is stored.
045:             */
046:            public static final String MESSAGE_SUPPORT_KEY = "de.odysseus.calyxo.control.message";
047:
048:            /**
049:             * Lookup message support for module determined by specified request
050:             */
051:            public static final MessageSupport getInstance(
052:                    HttpServletRequest request) {
053:                ModuleContext context = ModuleSupport.getInstance(request)
054:                        .getModuleContext(request);
055:                return (MessageSupport) context
056:                        .getAttribute(MESSAGE_SUPPORT_KEY);
057:            }
058:
059:            /**
060:             * Convenience method.
061:             * @see #getInstance(HttpServletRequest)
062:             */
063:            public static final MessageSupport getInstance(
064:                    PageContext pageContext) {
065:                return getInstance((HttpServletRequest) pageContext
066:                        .getRequest());
067:            }
068:
069:            /**
070:             * Lookup message support for specified module
071:             */
072:            public static final MessageSupport getInstance(ModuleContext context) {
073:                return (MessageSupport) context
074:                        .getAttribute(MESSAGE_SUPPORT_KEY);
075:            }
076:
077:            /**
078:             * Save the specified messages as errors for the specified request.
079:             * This will replace any existing error messages.
080:             * @param request the request we are processing
081:             * @param messages the messages to be saved
082:             */
083:            public abstract void setErrors(HttpServletRequest request,
084:                    Messages messages);
085:
086:            /**
087:             * Get error messages for the specified request.
088:             * @param request the request we are processing
089:             * @param create if <code>true</code>, create, save and return a new instance
090:             * if no error messages are present
091:             * @return messages instance or <code>null</code>
092:             */
093:            public abstract Messages getErrors(HttpServletRequest request,
094:                    boolean create);
095:
096:            /**
097:             * Add message as error message, associated with a key
098:             * @param request the request we are processing
099:             * @param key the key used when adding the message to the {@link Messages} object
100:             * @param message the message to be added
101:             */
102:            public final void addError(HttpServletRequest request, String key,
103:                    Message message) {
104:                getErrors(request, true).addMessage(key, message);
105:            }
106:
107:            /**
108:             * Add message as global error message
109:             * @param request the request we are processing
110:             * @param message the message to be added
111:             */
112:            public final void addError(HttpServletRequest request,
113:                    Message message) {
114:                getErrors(request, true).addGlobalMessage(message);
115:            }
116:
117:            /**
118:             * Save the specified messages as warnings for the specified request.
119:             * This will replace any existing warning messages.
120:             * @param request the request we are processing
121:             * @param messages the messages to be saved
122:             */
123:            public abstract void setWarnings(HttpServletRequest request,
124:                    Messages messages);
125:
126:            /**
127:             * Get warning messages for the specified request.
128:             * @param request the request we are processing
129:             * @param create if <code>true</code>, create, save and return a new instance
130:             * if no warning messages are present
131:             * @return messages instance or <code>null</code>
132:             */
133:            public abstract Messages getWarnings(HttpServletRequest request,
134:                    boolean create);
135:
136:            /**
137:             * Add message as warning message, associated with a key
138:             * @param request the request we are processing
139:             * @param key the key used when adding the message to the {@link Messages} object
140:             * @param message the message to be added
141:             */
142:            public final void addWarning(HttpServletRequest request,
143:                    String key, Message message) {
144:                getWarnings(request, true).addMessage(key, message);
145:            }
146:
147:            /**
148:             * Add message as global warning message
149:             * @param request the request we are processing
150:             * @param message the message to be added
151:             */
152:            public final void addWarning(HttpServletRequest request,
153:                    Message message) {
154:                getWarnings(request, true).addGlobalMessage(message);
155:            }
156:
157:            /**
158:             * Save the specified messages as infos for the specified request.
159:             * This will replace any existing info messages.
160:             * @param request the request we are processing
161:             * @param messages the messages to be saved
162:             */
163:            public abstract void setInfos(HttpServletRequest request,
164:                    Messages messages);
165:
166:            /**
167:             * Get info messages for the specified request.
168:             * @param request the request we are processing
169:             * @param create if <code>true</code>, create, save and return a new instance
170:             * if no info messages are present
171:             * @return messages instance or <code>null</code>
172:             */
173:            public abstract Messages getInfos(HttpServletRequest request,
174:                    boolean create);
175:
176:            /**
177:             * Add message as info message, associated with a key
178:             * @param request the request we are processing
179:             * @param key the key used when adding the message to the {@link Messages} object
180:             * @param message the message to be added
181:             */
182:            public final void addInfo(HttpServletRequest request, String key,
183:                    Message message) {
184:                getInfos(request, true).addMessage(key, message);
185:            }
186:
187:            /**
188:             * Add message as global info message
189:             * @param request the request we are processing
190:             * @param message the message to be added
191:             */
192:            public final void addInfo(HttpServletRequest request,
193:                    Message message) {
194:                getInfos(request, true).addGlobalMessage(message);
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.