Source Code Cross Referenced for JspAwareRequestContext.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » support » 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 » spring framework 2.0.6 » org.springframework.web.servlet.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 the original author or authors.
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:
017:        package org.springframework.web.servlet.support;
018:
019:        import java.util.Locale;
020:        import java.util.Map;
021:
022:        import javax.servlet.http.HttpServletRequest;
023:        import javax.servlet.jsp.PageContext;
024:
025:        /**
026:         * JSP-aware subclass of RequestContext, allowing population of the context
027:         * from a JSP PageContext.
028:         *
029:         * <p>This context will also detect a JSTL locale attribute in page scope,
030:         * in addition to the fallback locale strategy provided by the base class.
031:         *
032:         * @author Juergen Hoeller
033:         * @since 1.1.4
034:         * @see #getFallbackLocale
035:         */
036:        public class JspAwareRequestContext extends RequestContext {
037:
038:            protected static final String PAGE_SCOPE_SUFFIX = ".page";
039:
040:            private PageContext pageContext;
041:
042:            /**
043:             * Create a new JspAwareRequestContext for the given page context,
044:             * using the request attributes for Errors retrieval.
045:             * @param pageContext current JSP page context
046:             */
047:            public JspAwareRequestContext(PageContext pageContext) {
048:                initContext(pageContext, null);
049:            }
050:
051:            /**
052:             * Create a new JspAwareRequestContext for the given page context,
053:             * using the given model attributes for Errors retrieval.
054:             * @param pageContext current JSP page context
055:             * @param model the model attributes for the current view
056:             * (can be <code>null</code>, using the request attributes for Errors retrieval)
057:             */
058:            public JspAwareRequestContext(PageContext pageContext, Map model) {
059:                initContext(pageContext, model);
060:            }
061:
062:            /**
063:             * Initialize this context with the given page context,
064:             * using the given model attributes for Errors retrieval.
065:             * @param pageContext current JSP page context
066:             * @param model the model attributes for the current view
067:             * (can be <code>null</code>, using the request attributes for Errors retrieval)
068:             */
069:            protected void initContext(PageContext pageContext, Map model) {
070:                if (!(pageContext.getRequest() instanceof  HttpServletRequest)) {
071:                    throw new IllegalArgumentException(
072:                            "RequestContext only supports HTTP requests");
073:                }
074:                this .pageContext = pageContext;
075:                initContext((HttpServletRequest) pageContext.getRequest(),
076:                        pageContext.getServletContext(), model);
077:            }
078:
079:            /**
080:             * Return the underlying PageContext.
081:             * Only intended for cooperating classes in this package.
082:             */
083:            protected PageContext getPageContext() {
084:                return pageContext;
085:            }
086:
087:            /**
088:             * This implementation looks for a JSTL locale attribute in the
089:             * JSP page scope, falling back to the superclass if not found.
090:             * @see RequestContext#getFallbackLocale
091:             */
092:            protected Locale getFallbackLocale() {
093:                Locale locale = (Locale) getPageContext().getAttribute(
094:                        JSTL_LOCALE_ATTRIBUTE);
095:                if (locale == null) {
096:                    locale = (Locale) getPageContext().getAttribute(
097:                            JSTL_LOCALE_ATTRIBUTE + PAGE_SCOPE_SUFFIX);
098:                    if (locale == null) {
099:                        locale = super.getFallbackLocale();
100:                    }
101:                }
102:                return locale;
103:            }
104:
105:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.