Source Code Cross Referenced for MessageHandler.java in  » Portal » Open-Portal » com » sun » portal » app » blog » handler » 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 » Portal » Open Portal » com.sun.portal.app.blog.handler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright ? 2006 Sun Microsystems, Inc. All rights reserved. 
003:         *
004:         * Sun Microsystems, Inc. has intellectual property rights relating to
005:         * technology embodied in the product that is described in this document. 
006:         * In particular, and without limitation, these intellectual property 
007:         * rights may include one or more of the U.S. patents listed at 
008:         * http://www.sun.com/patents and one or more additional patents or
009:         * pending patent applications in the U.S. and in other countries.
010:         * 
011:         * U.S. Government Rights - Commercial software. Government users are subject
012:         * to the Sun Microsystems, Inc. standard license agreement and applicable 
013:         * provisions of the FAR and its supplements. Use is subject to license terms. 
014:         * This distribution may include materials developed by third parties.
015:         * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered 
016:         * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. 
017:         */
018:        package com.sun.portal.app.blog.handler;
019:
020:        import com.sun.portal.app.blog.Resources;
021:        import java.util.Iterator;
022:        import javax.faces.application.FacesMessage;
023:        import javax.faces.context.FacesContext;
024:
025:        public class MessageHandler {
026:            private static Resources resources = new Resources(
027:                    "com.sun.portal.app.blog.handler.MessageHandler");
028:
029:            public void addInfo(String info) {
030:                add(null, FacesMessage.SEVERITY_INFO, info, null);
031:            }
032:
033:            public void addError(String err) {
034:                addError(err, (Throwable) null);
035:            }
036:
037:            public void addError(String err, Throwable t) {
038:                addError(null, err, t);
039:            }
040:
041:            public void addError(String err, String detail) {
042:                addError(null, err, detail);
043:            }
044:
045:            public void addError(String id, String err, Throwable t) {
046:                String exceptionMsg = (t != null) ? t.getMessage() : null;
047:                //add(id, FacesMessage.SEVERITY_ERROR, err, exceptionMsg);
048:                // HACK: seems that JSF reverses the summary and detail
049:                // so call with arguments reversed
050:                add(id, FacesMessage.SEVERITY_ERROR, exceptionMsg, err);
051:            }
052:
053:            public void addError(String id, String err, String detail) {
054:                //add(id, FacesMessage.SEVERITY_ERROR, err, detail);
055:                // HACK: seems that JSF reverses the summary and detail
056:                // so call with arguments reversed
057:                add(id, FacesMessage.SEVERITY_ERROR, detail, err);
058:            }
059:
060:            private void add(String id, FacesMessage.Severity severity,
061:                    String err, String detail) {
062:                add(id, new FacesMessage(severity, err, detail));
063:            }
064:
065:            private void add(String id, FacesMessage fm) {
066:                if (!containsMessage(fm)) {
067:                    FacesContext.getCurrentInstance().addMessage(id, fm);
068:                }
069:            }
070:
071:            private static boolean containsMessage(FacesMessage fm) {
072:                for (Iterator i = FacesContext.getCurrentInstance()
073:                        .getMessages(null); i.hasNext();) {
074:                    FacesMessage msg = (FacesMessage) i.next();
075:                    if (messageEquals(fm, msg)) {
076:                        return true;
077:                    }
078:                }
079:                return false;
080:            }
081:
082:            private static boolean messageEquals(FacesMessage fm1,
083:                    FacesMessage fm2) {
084:                if (!fm1.getSummary().equals(fm2.getSummary())) {
085:                    return false;
086:                }
087:                if (!fm1.getDetail().equals(fm2.getDetail())) {
088:                    return false;
089:                }
090:                if (fm1.getSeverity().compareTo(fm2.getSeverity()) != 0) {
091:                    return false;
092:                }
093:
094:                return true;
095:
096:            }
097:
098:            public boolean isGlobalMessagesPresent() {
099:                // test if there are any GLOBAL messages
100:                if (!FacesContext.getCurrentInstance().getMessages(null)
101:                        .hasNext()) {
102:                    return false;
103:                }
104:                return true;
105:            }
106:
107:            private boolean isErrorPresent() {
108:                FacesMessage.Severity severity = FacesContext
109:                        .getCurrentInstance().getMaximumSeverity();
110:                if (severity == FacesMessage.SEVERITY_ERROR) {
111:                    return true;
112:                }
113:                return false;
114:            }
115:
116:            public String getIcon() {
117:                if (isErrorPresent()) {
118:                    return resources.get("getIcon.errorIcon");
119:                } else {
120:                    return resources.get("getIcon.infoIcon");
121:                }
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.