Source Code Cross Referenced for ViewHandlerImpl.java in  » Portal » Open-Portal » com » sun » faces » portlet » 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.faces.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ViewHandlerImpl.java,v 1.5 2006/06/13 09:45:55 dg154973 Exp $
003:         */
004:
005:        /*
006:         * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
007:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
008:         */
009:
010:        package com.sun.faces.portlet;
011:
012:        import java.io.IOException;
013:        import java.util.Locale;
014:
015:        import javax.faces.application.ViewHandler;
016:        import javax.faces.component.UIViewRoot;
017:        import javax.faces.context.FacesContext;
018:        import javax.faces.context.ResponseWriter;
019:        import javax.faces.FacesException;
020:
021:        import javax.portlet.PortletURL;
022:        import javax.portlet.RenderResponse;
023:
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:
027:        /**
028:         * <p>Concrete implementation of <code>ViewHandler</code> for use in
029:         * a portlet environment.  This implementation delegates to the
030:         * standard <codeViewHandler</code> instance provided to our constructor,
031:         * and only implements portlet-specific behavior where necessary.</p>
032:         */
033:
034:        public final class ViewHandlerImpl extends ViewHandler {
035:
036:            // ------------------------------------------------------------- Constructor
037:
038:            /**
039:             * <p>Construct a new <code>ViewHandler</code> instance that delegates
040:             * all non-portlet-specific behavior to the specified implementation.
041:             *
042:             * @param handler The <code>ViewHandler</code> instance to whom
043:             *  we can delegate
044:             *
045:             * @exception NullPointerException if <code>handler</code>
046:             *  is <code>null</code>
047:             */
048:            public ViewHandlerImpl(ViewHandler handler) {
049:
050:                if (handler == null) {
051:                    throw new NullPointerException();
052:                }
053:                if (log.isDebugEnabled()) {
054:                    log.debug("Delegating to '" + handler + "'");
055:                }
056:                this .handler = handler;
057:
058:            }
059:
060:            // -------------------------------------------------------- Static Variables
061:
062:            /**
063:             * <p>The URL parameter we use to pass the view identifier of the
064:             * requested view.</p>
065:             */
066:            public static final String VIEW_ID_PARAMETER = "com.sun.faces.portlet.VIEW_ID";
067:
068:            /**
069:             * <p>The URL parameter we use to pass the namespace of the portlet.</p>
070:             */
071:            public static final String NAME_SPACE_PARAMETER = "com.sun.faces.portlet.NAME_SPACE";
072:
073:            // The Log instance for this class
074:            private static final Log log = LogFactory
075:                    .getLog(ViewHandlerImpl.class);
076:
077:            // ------------------------------------------------------ Instance Variables
078:
079:            // The ViewHandler we delegate to
080:            private ViewHandler handler;
081:
082:            // ----------------------------------------------------- ViewHandler Methods
083:
084:            public Locale calculateLocale(FacesContext context) {
085:                return (handler.calculateLocale(context));
086:            }
087:
088:            public String calculateRenderKitId(FacesContext context) {
089:                return (handler.calculateRenderKitId(context));
090:            }
091:
092:            public UIViewRoot createView(FacesContext context, String viewId) {
093:                return (handler.createView(context, viewId));
094:            }
095:
096:            public String getActionURL(FacesContext context, String viewId) {
097:                Object r = context.getExternalContext().getResponse();
098:                if (!(r instanceof  RenderResponse)) {
099:                    if (log.isDebugEnabled()) {
100:                        log.debug("Must be a RenderResponse");
101:                    }
102:                    throw new IllegalStateException("Must be a RenderResponse");
103:                }
104:                RenderResponse response = (RenderResponse) r;
105:                PortletURL actionURL = response.createActionURL();
106:                actionURL.setParameter(VIEW_ID_PARAMETER, viewId);
107:                if (log.isTraceEnabled()) {
108:                    log.trace("Action URL:" + actionURL.toString());
109:                }
110:                return (actionURL.toString());
111:            }
112:
113:            public String getResourceURL(FacesContext context, String path) {
114:                return (handler.getResourceURL(context, path));
115:            }
116:
117:            public void renderView(FacesContext context, UIViewRoot viewToRender)
118:                    throws IOException, FacesException {
119:                handler.renderView(context, viewToRender);
120:            }
121:
122:            public UIViewRoot restoreView(FacesContext context, String viewId) {
123:                return (handler.restoreView(context, viewId));
124:            }
125:
126:            public void writeState(FacesContext context) throws IOException {
127:                handler.writeState(context);
128:                // A unique value is needed while saving values in the session.
129:                // As the rendee response namespace is unique, we write the namespace obtainer
130:                // from the render response as hidden field and send it with the page. 
131:                ResponseWriter writer = context.getResponseWriter();
132:                RenderResponse response = (RenderResponse) context
133:                        .getExternalContext().getResponse();
134:                writer.startElement("input", context.getViewRoot());
135:                writer.writeAttribute("type", "hidden", null);
136:                writer.writeAttribute("name", NAME_SPACE_PARAMETER, null);
137:                writer.writeAttribute("id", NAME_SPACE_PARAMETER, null);
138:                writer.writeAttribute("value", response.getNamespace(), null);
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.