Source Code Cross Referenced for ViewHandlerImpl.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » faces » application » 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 » Web Framework » struts 1.3.8 » org.apache.struts.faces.application 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ViewHandlerImpl.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        package org.apache.struts.faces.application;
023:
024:        import java.io.IOException;
025:        import java.util.Locale;
026:        import javax.faces.FacesException;
027:        import javax.faces.application.ViewHandler;
028:        import javax.faces.component.UIViewRoot;
029:        import javax.faces.context.ExternalContext;
030:        import javax.faces.context.FacesContext;
031:
032:        import org.apache.commons.logging.Log;
033:        import org.apache.commons.logging.LogFactory;
034:        import org.apache.struts.Globals;
035:
036:        /**
037:         * <p>Custom <code>ViewHandler</code> implementation that adds features
038:         * specific to the Struts-Faces Integration Library.  It leverages the
039:         * "decorator pattern" customization strategy that JSF supports, by
040:         * delegating most processing to the <code>ViewHandler</code> instance
041:         * handed to our constructor.</p>
042:         */
043:
044:        public class ViewHandlerImpl extends ViewHandler {
045:
046:            // ------------------------------------------------------------ Constructors
047:
048:            /**
049:             * <p>Construct a <code>ViewHandlerImpl</code> decorating the
050:             * specified <code>ViewHandler</code> instance.</p>
051:             *
052:             * @param handler <code>ViewHandler</code> to be decorated
053:             */
054:            public ViewHandlerImpl(ViewHandler handler) {
055:                if (log.isDebugEnabled()) {
056:                    log
057:                            .debug("Creating ViewHandler instance, wrapping handler "
058:                                    + handler);
059:                }
060:                this .handler = handler;
061:            }
062:
063:            // ------------------------------------------------------ Instance Variables
064:
065:            /**
066:             * <p>The <code>ViewHandler</code> instance that we are decorating.</p>
067:             */
068:            private ViewHandler handler = null;
069:
070:            // -------------------------------------------------------- Static Variables
071:
072:            /**
073:             * <p>The <code>Log</code> instance for this class.</p>
074:             */
075:            private static final Log log = LogFactory
076:                    .getLog(ViewHandlerImpl.class);
077:
078:            // -------------------------------------------------------------- Properties
079:
080:            /**
081:             * <p>Return the <code>ViewHandler</code> instance we are decorating.</p>
082:             */
083:            public ViewHandler getHandler() {
084:                return this .handler;
085:            }
086:
087:            /**
088:             * <p>Set the <code>ViewHandler</code> instance we are decorating.</p>
089:             *
090:             * @param handler <code>ViewHandler</code> instance to decorate
091:             */
092:            public void setHandler(ViewHandler handler) {
093:                this .handler = handler;
094:            }
095:
096:            // ----------------------------------------------------- Specialized Methods
097:
098:            /**
099:             * <p>If the Struts application has set a <code>Locale</code>, pass it
100:             * on to JSF prior to delegating the actual rendering.</p>
101:             *
102:             * @param context <code>FacesContext</code> for the current request
103:             * @param view <code>UIViewRoot</code> to be rendered
104:             */
105:            public void renderView(FacesContext context, UIViewRoot view)
106:                    throws IOException, FacesException {
107:
108:                if (log.isDebugEnabled()) {
109:                    log.debug("renderView(" + view.getViewId() + ")");
110:                }
111:                ExternalContext econtext = context.getExternalContext();
112:                if (econtext.getSession(false) != null) {
113:                    Locale locale = (Locale) econtext.getSessionMap().get(
114:                            Globals.LOCALE_KEY);
115:                    if (locale != null) {
116:                        if (log.isTraceEnabled()) {
117:                            log.trace("Setting view locale to " + locale);
118:                        }
119:                        view.setLocale(locale);
120:                    }
121:                }
122:                handler.renderView(context, view);
123:
124:            }
125:
126:            // ------------------------------------------------------- Delegated Methods
127:
128:            // See ViewHandler JavaDocs for method descriptions
129:
130:            public Locale calculateLocale(FacesContext context) {
131:                return handler.calculateLocale(context);
132:            }
133:
134:            public String calculateRenderKitId(FacesContext context) {
135:                return handler.calculateRenderKitId(context);
136:            }
137:
138:            public UIViewRoot createView(FacesContext context, String viewId) {
139:                return handler.createView(context, viewId);
140:            }
141:
142:            public String getActionURL(FacesContext context, String viewId) {
143:                return handler.getActionURL(context, viewId);
144:            }
145:
146:            public String getResourceURL(FacesContext context, String viewId) {
147:                return handler.getResourceURL(context, viewId);
148:            }
149:
150:            public UIViewRoot restoreView(FacesContext context, String viewId) {
151:                return handler.restoreView(context, viewId);
152:            }
153:
154:            public void writeState(FacesContext context) throws IOException {
155:                handler.writeState(context);
156:            }
157:
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.