Source Code Cross Referenced for MessagingBean.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » section » jsf » 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 » ERP CRM Financial » sakai » org.sakaiproject.tool.section.jsf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sections/tags/sakai_2-4-1/sections-app-util/src/java/org/sakaiproject/tool/section/jsf/MessagingBean.java $
003:         * $Id: MessagingBean.java 20002 2006-12-22 19:52:45Z jholtzman@berkeley.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006 The Regents of the University of California and The Regents of the University of Michigan
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.tool.section.jsf;
021:
022:        import java.io.Serializable;
023:        import java.util.ArrayList;
024:        import java.util.Iterator;
025:        import java.util.List;
026:
027:        import javax.faces.application.FacesMessage;
028:        import javax.faces.application.FacesMessage.Severity;
029:
030:        import org.apache.commons.lang.builder.EqualsBuilder;
031:        import org.apache.commons.lang.builder.HashCodeBuilder;
032:
033:        /**
034:         * A session-scoped bean to handle jsf messages across redirects.
035:         *
036:         * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
037:         */
038:        public class MessagingBean {
039:            private List messages;
040:
041:            public MessagingBean() {
042:                messages = new ArrayList();
043:            }
044:
045:            public boolean hasMessages() {
046:                return messages.size() > 0;
047:            }
048:
049:            /**
050:             * Returns the current list of FacesMessages, then removes them from the local list.
051:             * @return
052:             */
053:            public List getMessagesAndClear() {
054:                List list = new ArrayList();
055:                for (Iterator iter = messages.iterator(); iter.hasNext();) {
056:                    list.add(((MessageDecorator) iter.next()).getMessage());
057:                }
058:                messages.clear();
059:                return list;
060:            }
061:
062:            /**
063:             * Adds a unique message.
064:             * 
065:             * @param message
066:             */
067:            public void addMessage(FacesMessage message) {
068:                // Don't add the message twice (in case of double-clicks).  Somewhat related to SAK-3553
069:                MessageDecorator decoratedMessage = new MessageDecorator(
070:                        message);
071:                if (!messages.contains(decoratedMessage)) {
072:                    messages.add(decoratedMessage);
073:                }
074:            }
075:
076:            /**
077:             * Used in place of standard FacesMessage.  Overrides equals so we can add
078:             * unique messages and avoid duplicates.
079:             * 
080:             * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
081:             *
082:             */
083:            class MessageDecorator implements  Serializable {
084:                private static final long serialVersionUID = 1L;
085:
086:                FacesMessage message;
087:
088:                public MessageDecorator(FacesMessage message) {
089:                    this .message = message;
090:                }
091:
092:                public FacesMessage getMessage() {
093:                    return message;
094:                }
095:
096:                public boolean equals(Object o) {
097:                    MessageDecorator other = (MessageDecorator) o;
098:                    return new EqualsBuilder().append(getSeverity(),
099:                            other.getSeverity()).append(getDetail(),
100:                            other.getDetail()).append(getSummary(),
101:                            other.getSummary()).isEquals();
102:                }
103:
104:                public int hashCode() {
105:                    return new HashCodeBuilder(17, 37).append(getSeverity())
106:                            .append(getDetail()).append(getSummary())
107:                            .toHashCode();
108:                }
109:
110:                public String getDetail() {
111:                    return message.getDetail();
112:                }
113:
114:                public Severity getSeverity() {
115:                    return message.getSeverity();
116:                }
117:
118:                public String getSummary() {
119:                    return message.getSummary();
120:                }
121:
122:                public void setDetail(String arg0) {
123:                    message.setDetail(arg0);
124:                }
125:
126:                public void setSeverity(Severity arg0) {
127:                    message.setSeverity(arg0);
128:                }
129:
130:                public void setSummary(String arg0) {
131:                    message.setSummary(arg0);
132:                }
133:
134:                public String toString() {
135:                    return message.toString();
136:                }
137:
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.