Source Code Cross Referenced for Exceptions.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » html » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.html;
020:
021:        import org.apache.beehive.netui.util.internal.InternalStringBuilder;
022:
023:        import org.apache.beehive.netui.pageflow.internal.AdapterManager;
024:        import org.apache.beehive.netui.tags.AbstractSimpleTag;
025:        import org.apache.beehive.netui.util.HtmlExceptionFormatter;
026:        import org.apache.struts.Globals;
027:        import org.apache.struts.util.ResponseUtils;
028:
029:        import javax.servlet.ServletRequest;
030:        import javax.servlet.jsp.JspException;
031:        import javax.servlet.jsp.PageContext;
032:
033:        /**
034:         * Renders formatted exception data, as found in the Request with the key:
035:         * <code>org.apache.struts.action.Action.EXCEPTION_KEY</code>.  Exceptions ignores its
036:         * body content.
037:         * @jsptagref.tagdescription Renders exception messages and stack traces inline on the JSP page.
038:         * @example In this sample, the &lt;netui:exceptions> tag will output the exception title and message,
039:         * but not the stacktraces.
040:         * <pre>&lt;netui:exceptions showMessage="true" showStackTrace="false" /></pre>
041:         * @netui:tag name="exceptions" body-content="empty" description="Displays formatted exception messages."
042:         */
043:        public class Exceptions extends AbstractSimpleTag {
044:            private boolean _showMessage = true;
045:            private boolean _showStackTrace = false;
046:            private boolean _showDevModeStackTrace = false;
047:
048:            /**
049:             * Return the name of the Tag.
050:             */
051:            public String getTagName() {
052:                return "Exceptions";
053:            }
054:
055:            /**
056:             * Set whether or not the exception message is being shown.
057:             * @param showMessage true or false depending on the setting desired
058:             * @jsptagref.attributedescription Boolean. Determines whether or not the exception message is shown. Defaults to <code>true</code>
059:             * @jsptagref.databindable false
060:             * @jsptagref.attributesyntaxvalue <i>boolean_showMessage</i>
061:             * @netui:attribute required="false" rtexprvalue="true" type="boolean"
062:             * description="Determines whether or not the exception message is shown. Defaults to true."
063:             */
064:            public void setShowMessage(boolean showMessage) {
065:                _showMessage = showMessage;
066:            }
067:
068:            /**
069:             * Set whether or not the stack trace is being shown.
070:             * @param showStackTrace true or false depending on the setting desired
071:             * @jsptagref.attributedescription Boolean.  Determines whether or not the stack trace is shown. Defaults to <code>false</code>
072:             * @jsptagref.databindable false
073:             * @jsptagref.attributesyntaxvalue <i>boolean_showStackTrace</i>
074:             * @netui:attribute required="false" rtexprvalue="true" type="boolean"
075:             * description="Determines whether or not the stack trace is shown. Defaults to false."
076:             */
077:            public void setShowStackTrace(boolean showStackTrace) {
078:                _showStackTrace = showStackTrace;
079:            }
080:
081:            /**
082:             * Set whether or not the stack trace is being shown.
083:             * @param showStackTrace true or false depending on the setting desired
084:             * @jsptagref.attributedescription Boolean. Determine if the stack trace is display only when dev mode
085:             * is on.  Default is <code>true</code>.
086:             * @jsptagref.databindable false
087:             * @jsptagref.attributesyntaxvalue <i>boolean_showDevModeStackTrace</i>
088:             * @netui:attribute required="false" rtexprvalue="true" type="boolean"
089:             * description="Determine if the stack trace is display only when dev mode is on.  Default is true."
090:             */
091:            public void setShowDevModeStackTrace(boolean showStackTrace) {
092:                _showDevModeStackTrace = showStackTrace;
093:            }
094:
095:            /**
096:             * Render the exception text based on the display attributes.
097:             * @throws JspException if a JSP exception has occurred
098:             */
099:            public void doTag() throws JspException {
100:                // First look for the exception in the pageflow/struts request attribute.  If it's not there,
101:                // look for it in the request attribute the container provides for web.xml-configured error
102:                // pages.
103:                InternalStringBuilder results = new InternalStringBuilder(128);
104:                PageContext pageContext = getPageContext();
105:                Throwable e = (Throwable) pageContext.getAttribute(
106:                        Globals.EXCEPTION_KEY, PageContext.REQUEST_SCOPE);
107:
108:                if (e == null) {
109:                    ServletRequest req = pageContext.getRequest();
110:                    e = (Throwable) req
111:                            .getAttribute("javax.servlet.error.exception");
112:                    if (e == null) {
113:                        e = (Throwable) req
114:                                .getAttribute("javax.servlet.jsp.jspException");
115:                    }
116:                }
117:
118:                if (!_showStackTrace && _showDevModeStackTrace) {
119:                    boolean devMode = !AdapterManager
120:                            .getServletContainerAdapter(
121:                                    pageContext.getServletContext())
122:                            .isInProductionMode();
123:                    if (devMode)
124:                        _showStackTrace = true;
125:                }
126:
127:                if (e != null) {
128:                    if (_showMessage) {
129:                        String msg = e.getMessage();
130:                        // if we have message lets output the exception name and the name of the
131:                        if ((msg != null) && (msg.length() > 0)) {
132:                            if (!_showStackTrace)
133:                                msg = e.getClass().getName() + ": " + msg;
134:                            results.append(HtmlExceptionFormatter.format(msg,
135:                                    e, _showStackTrace));
136:                        } else {
137:                            results.append(HtmlExceptionFormatter.format(e
138:                                    .getClass().getName(), e, _showStackTrace));
139:                        }
140:                    } else {
141:                        results.append(HtmlExceptionFormatter.format(null, e,
142:                                _showStackTrace));
143:                    }
144:                    ResponseUtils.write(pageContext, results.toString());
145:                }
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.