Source Code Cross Referenced for DefaultExceptionResponseStrategy.java in  » J2EE » wicket » wicket » request » compound » 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 » wicket » wicket.request.compound 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DefaultExceptionResponseStrategy.java,v 1.1 2005/11/27 09:20:16 eelco12
003:         * Exp $ $Revision: 461835 $ $Date: 2006-08-15 17:45:42 +0200 (Tue, 15 Aug 2006) $
004:         * 
005:         * ==============================================================================
006:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007:         * use this file except in compliance with the License. You may obtain a copy of
008:         * the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015:         * License for the specific language governing permissions and limitations under
016:         * the License.
017:         */
018:        package wicket.request.compound;
019:
020:        import wicket.Application;
021:        import wicket.Page;
022:        import wicket.RequestCycle;
023:        import wicket.RestartResponseAtInterceptPageException;
024:        import wicket.RestartResponseException;
025:        import wicket.Session;
026:        import wicket.WicketRuntimeException;
027:        import wicket.authorization.AuthorizationException;
028:        import wicket.markup.html.pages.ExceptionErrorPage;
029:        import wicket.settings.IExceptionSettings;
030:
031:        /**
032:         * Default implementation of
033:         * {@link wicket.request.compound.IExceptionResponseStrategy}. Depending on the
034:         * setting it returns a (pluggable) exception page or a blank page, and it
035:         * passes the exception through to the current request cycle by calling
036:         * {@link wicket.RequestCycle#onRuntimeException(Page, RuntimeException)}.
037:         * 
038:         * @author Eelco Hillenius
039:         * @author Johan Compagner
040:         * @author Igor Vaynberg (ivaynberg)
041:         */
042:        public class DefaultExceptionResponseStrategy implements 
043:                IExceptionResponseStrategy {
044:
045:            /**
046:             * Construct.
047:             */
048:            public DefaultExceptionResponseStrategy() {
049:            }
050:
051:            /**
052:             * @see wicket.request.compound.IExceptionResponseStrategy#respond(wicket.RequestCycle,
053:             *      java.lang.RuntimeException)
054:             */
055:            public final void respond(final RequestCycle requestCycle,
056:                    final RuntimeException e) {
057:                // If application doesn't want debug info showing up for users
058:                final Session session = requestCycle.getSession();
059:                final Application application = session.getApplication();
060:                final IExceptionSettings settings = application
061:                        .getExceptionSettings();
062:                final Page responsePage = requestCycle.getResponsePage();
063:
064:                Page override = onRuntimeException(responsePage, e);
065:                if (override != null) {
066:                    throw new RestartResponseException(override);
067:                } else if (e instanceof  AuthorizationException) {
068:                    // are authorization exceptions always thrown before the real render?
069:                    // else we need to make a page (see below) or set it hard to a redirect.
070:                    Class accessDeniedPageClass = application
071:                            .getApplicationSettings().getAccessDeniedPage();
072:
073:                    throw new RestartResponseAtInterceptPageException(
074:                            accessDeniedPageClass);
075:                } else if (settings.getUnexpectedExceptionDisplay() != IExceptionSettings.SHOW_NO_EXCEPTION_PAGE) {
076:                    // we do not want to redirect - we want to inline the error output
077:                    // and preserve the url so when the refresh button is pressed we
078:                    // rerun the code that caused the error
079:                    requestCycle.setRedirect(false);
080:
081:                    // figure out which error page to show
082:                    Class internalErrorPageClass = application
083:                            .getApplicationSettings().getInternalErrorPage();
084:                    Class responseClass = responsePage != null ? responsePage
085:                            .getClass() : null;
086:
087:                    if (responseClass != internalErrorPageClass
088:                            && settings.getUnexpectedExceptionDisplay() == IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE) {
089:                        throw new RestartResponseException(
090:                                internalErrorPageClass);
091:                    } else if (responseClass != ExceptionErrorPage.class) {
092:                        // Show full details
093:                        throw new RestartResponseException(
094:                                new ExceptionErrorPage(e, responsePage));
095:                    } else {
096:                        // give up while we're ahead!
097:                        throw new WicketRuntimeException(
098:                                "Internal Error: Could not render error page "
099:                                        + internalErrorPageClass, e);
100:                    }
101:                }
102:            }
103:
104:            /**
105:             * This method is called when a runtime exception is thrown, just before the
106:             * actual handling of the runtime exception. This implemention passes the
107:             * call through to
108:             * {@link RequestCycle#onRuntimeException(Page, RuntimeException)}. Note
109:             * that if you override this method or provide a whole new implementation of
110:             * {@link IExceptionResponseStrategy} alltogether,
111:             * {@link RequestCycle#onRuntimeException(Page, RuntimeException)} will not
112:             * be supported.
113:             * 
114:             * @param page
115:             *            Any page context where the exception was thrown
116:             * @param e
117:             *            The exception
118:             * @return Any error page to redirect to
119:             */
120:            protected Page onRuntimeException(final Page page,
121:                    final RuntimeException e) {
122:                return RequestCycle.get().onRuntimeException(page, e);
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.