Source Code Cross Referenced for ActionResponse.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » environment » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.environment.portlet 
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:        package org.apache.cocoon.environment.portlet;
018:
019:        import org.apache.cocoon.util.NetUtils;
020:
021:        import org.apache.avalon.framework.CascadingRuntimeException;
022:
023:        import javax.portlet.PortletMode;
024:        import javax.portlet.PortletModeException;
025:        import javax.portlet.PortletPreferences;
026:        import javax.portlet.WindowState;
027:        import javax.portlet.WindowStateException;
028:
029:        import java.io.IOException;
030:        import java.util.HashMap;
031:        import java.util.Iterator;
032:        import java.util.Map;
033:
034:        /**
035:         * Implements the {@link org.apache.cocoon.environment.Response} interface for
036:         * the JSR-168 (Portlet) environment.
037:         *
038:         * @author <a href="mailto:vadim.gritsenko@dc.gov">Vadim Gritsenko</a>
039:         * @version CVS $Id: ActionResponse.java 433543 2006-08-22 06:22:54Z crossley $
040:         */
041:        public final class ActionResponse extends PortletResponse {
042:
043:            private String uri;
044:            private ActionRequest request;
045:
046:            /**
047:             * Creates a ActionResponse based on a real
048:             * {@link ActionResponse} object
049:             */
050:            protected ActionResponse(javax.portlet.ActionResponse response,
051:                    PortletPreferences preferences, ActionRequest request,
052:                    String uri) {
053:                super (response, preferences);
054:                this .request = request;
055:                this .uri = uri;
056:            }
057:
058:            // Response API methods
059:
060:            /**
061:             *
062:             * @see PortletEnvironment#HEADER_PORTLET_MODE
063:             * @see PortletEnvironment#HEADER_WINDOW_STATE
064:             */
065:            public void addHeader(String name, String value) {
066:                if (PortletEnvironment.HEADER_PORTLET_MODE.equals(name)) {
067:                    try {
068:                        this .getActionResponse().setPortletMode(
069:                                new PortletMode(value));
070:                    } catch (PortletModeException e) {
071:                        throw new CascadingRuntimeException(
072:                                "Cant set portlet mode '" + value + "'", e);
073:                    }
074:                } else if (PortletEnvironment.HEADER_WINDOW_STATE.equals(name)) {
075:                    try {
076:                        this .getActionResponse().setWindowState(
077:                                new WindowState(value));
078:                    } catch (WindowStateException e) {
079:                        throw new CascadingRuntimeException(
080:                                "Cant set window state '" + value + "'", e);
081:                    }
082:                } else {
083:                    super .addHeader(name, value);
084:                }
085:            }
086:
087:            /**
088:             *
089:             * @see PortletEnvironment#HEADER_PORTLET_MODE
090:             * @see PortletEnvironment#HEADER_WINDOW_STATE
091:             */
092:            public void setHeader(String name, String value) {
093:                if (PortletEnvironment.HEADER_PORTLET_MODE.equals(name)) {
094:                    try {
095:                        this .getActionResponse().setPortletMode(
096:                                new PortletMode(value));
097:                    } catch (PortletModeException e) {
098:                        throw new CascadingRuntimeException(
099:                                "Cant set portlet mode '" + value + "'", e);
100:                    }
101:                } else if (PortletEnvironment.HEADER_WINDOW_STATE.equals(name)) {
102:                    try {
103:                        this .getActionResponse().setWindowState(
104:                                new WindowState(value));
105:                    } catch (WindowStateException e) {
106:                        throw new CascadingRuntimeException(
107:                                "Cant set window state '" + value + "'", e);
108:                    }
109:                } else {
110:                    super .setHeader(name, value);
111:                }
112:            }
113:
114:            /**
115:             * Implements redirect.
116:             *
117:             * Redirects to self (starting with the question mark) are processed
118:             * differently from other redirects: redirect parameters are parsed and
119:             * set on response using {@link ActionResponse#setRenderParameter(String, String)}
120:             * method, {@link ActionResponse#sendRedirect(String)} method is not called.
121:             *
122:             * @param location
123:             * @throws IOException
124:             */
125:            public void sendRedirect(String location) throws IOException {
126:                String servletPath = this .request.getServletPath();
127:
128:                // Strip off parameters
129:                Map parameters = new HashMap(7);
130:                String absLoc = NetUtils.deparameterize(location, parameters);
131:
132:                // Absolutize
133:                if (absLoc.length() > 0) {
134:                    String base = NetUtils.getPath(uri);
135:                    absLoc = NetUtils.absolutize(base, absLoc);
136:                    absLoc = NetUtils.normalize(absLoc);
137:                } else {
138:                    absLoc = uri;
139:                }
140:
141:                // Redirect within the portlet?
142:                if (absLoc.startsWith(servletPath)) {
143:                    String pathInfo = absLoc.substring(servletPath.length());
144:
145:                    for (Iterator i = parameters.entrySet().iterator(); i
146:                            .hasNext();) {
147:                        Map.Entry me = (Map.Entry) i.next();
148:                        String name = (String) me.getKey();
149:                        String value = (String) me.getValue();
150:                        getActionResponse().setRenderParameter(name, value);
151:                    }
152:                    getActionResponse().setRenderParameter(
153:                            PortletEnvironment.PARAMETER_PATH_INFO, pathInfo);
154:                } else {
155:                    getActionResponse().sendRedirect(location);
156:                }
157:
158:                /*
159:                 if (location.startsWith("?")) {
160:                 Map parameters = new HashMap(7);
161:                 NetUtils.deparameterize(location, parameters);
162:                 for (Iterator i = parameters.keySet().iterator(); i.hasNext();) {
163:                 String name = (String)i.next();
164:                 String value = (String)parameters.get(name);
165:                 getActionResponse().setRenderParameter(name, value);
166:                 }
167:                 } else {
168:                 getActionResponse().sendRedirect(location);
169:                 }
170:                 */
171:            }
172:
173:            // ActionResponse API methods
174:
175:            /**
176:             * Type cast portletResponse to {@link ActionResponse}
177:             *
178:             * @return type casted portletResponse
179:             */
180:            public javax.portlet.ActionResponse getActionResponse() {
181:                return (javax.portlet.ActionResponse) getPortletResponse();
182:            }
183:
184:            public void setPortletMode(PortletMode mode)
185:                    throws PortletModeException {
186:                getActionResponse().setPortletMode(mode);
187:            }
188:
189:            public void setRenderParameter(String key, String value) {
190:                getActionResponse().setRenderParameter(key, value);
191:            }
192:
193:            public void setRenderParameter(String key, String[] values) {
194:                getActionResponse().setRenderParameter(key, values);
195:            }
196:
197:            public void setRenderParameters(Map parameters) {
198:                getActionResponse().setRenderParameters(parameters);
199:            }
200:
201:            public void setWindowState(WindowState state)
202:                    throws WindowStateException {
203:                getActionResponse().setWindowState(state);
204:            }
205:
206:            // Portlet Environment API methods
207:
208:            /**
209:             * Action response is always committed (in a sense that you cannot reset() response)
210:             */
211:            boolean isCommitted() {
212:                return true;
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.