Source Code Cross Referenced for PortletActionContext.java in  » Web-Framework » struts-2.0.11 » org » apache » struts2 » portlet » context » 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 2.0.11 » org.apache.struts2.portlet.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PortletActionContext.java 568895 2007-08-23 08:57:36Z rgielen $
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:        package org.apache.struts2.portlet.context;
022:
023:        import java.util.Map;
024:
025:        import javax.portlet.*;
026:
027:        import org.apache.struts2.dispatcher.mapper.ActionMapping;
028:        import org.apache.struts2.portlet.PortletActionConstants;
029:        import org.apache.struts2.StrutsStatics;
030:
031:        import com.opensymphony.xwork2.ActionContext;
032:
033:        /**
034:         * PortletActionContext. ActionContext thread local for the portlet environment.
035:         *
036:         * @version $Revision: 568895 $ $Date: 2007-08-23 04:57:36 -0400 (Thu, 23 Aug 2007) $
037:         */
038:        public class PortletActionContext implements  PortletActionConstants {
039:
040:            /**
041:             * Get the PortletConfig of the portlet that is executing.
042:             *
043:             * @return The PortletConfig of the executing portlet.
044:             */
045:            public static PortletConfig getPortletConfig() {
046:                return (PortletConfig) getContext().get(PORTLET_CONFIG);
047:            }
048:
049:            /**
050:             * Get the RenderRequest. Can only be invoked in the render phase.
051:             *
052:             * @return The current RenderRequest.
053:             * @throws IllegalStateException If the method is invoked in the wrong phase.
054:             */
055:            public static RenderRequest getRenderRequest() {
056:                if (!isRender()) {
057:                    throw new IllegalStateException(
058:                            "RenderRequest cannot be obtained in event phase");
059:                }
060:                return (RenderRequest) getContext().get(REQUEST);
061:            }
062:
063:            /**
064:             * Get the RenderResponse. Can only be invoked in the render phase.
065:             *
066:             * @return The current RenderResponse.
067:             * @throws IllegalStateException If the method is invoked in the wrong phase.
068:             */
069:            public static RenderResponse getRenderResponse() {
070:                if (!isRender()) {
071:                    throw new IllegalStateException(
072:                            "RenderResponse cannot be obtained in event phase");
073:                }
074:                return (RenderResponse) getContext().get(RESPONSE);
075:            }
076:
077:            /**
078:             * Get the ActionRequest. Can only be invoked in the event phase.
079:             *
080:             * @return The current ActionRequest.
081:             * @throws IllegalStateException If the method is invoked in the wrong phase.
082:             */
083:            public static ActionRequest getActionRequest() {
084:                if (!isEvent()) {
085:                    throw new IllegalStateException(
086:                            "ActionRequest cannot be obtained in render phase");
087:                }
088:                return (ActionRequest) getContext().get(REQUEST);
089:            }
090:
091:            /**
092:             * Get the ActionRequest. Can only be invoked in the event phase.
093:             *
094:             * @return The current ActionRequest.
095:             * @throws IllegalStateException If the method is invoked in the wrong phase.
096:             */
097:            public static ActionResponse getActionResponse() {
098:                if (!isEvent()) {
099:                    throw new IllegalStateException(
100:                            "ActionResponse cannot be obtained in render phase");
101:                }
102:                return (ActionResponse) getContext().get(RESPONSE);
103:            }
104:
105:            /**
106:             * Get the action namespace of the portlet. Used to organize actions for multiple portlets in
107:             * the same portlet application.
108:             *
109:             * @return The portlet namespace as defined in <code>portlet.xml</code> and <code>struts.xml</code>
110:             */
111:            public static String getPortletNamespace() {
112:                return (String) getContext().get(PORTLET_NAMESPACE);
113:            }
114:
115:            /**
116:             * Get the current PortletRequest.
117:             *
118:             * @return The current PortletRequest.
119:             */
120:            public static PortletRequest getRequest() {
121:                return (PortletRequest) getContext().get(REQUEST);
122:            }
123:
124:            /**
125:             * Get the current PortletResponse
126:             *
127:             * @return The current PortletResponse.
128:             */
129:            public static PortletResponse getResponse() {
130:                return (PortletResponse) getContext().get(RESPONSE);
131:            }
132:
133:            /**
134:             * Get the phase that the portlet is executing in.
135:             *
136:             * @return {@link PortletActionConstants#RENDER_PHASE} in render phase, and
137:             * {@link PortletActionConstants#EVENT_PHASE} in the event phase.
138:             */
139:            public static Integer getPhase() {
140:                return (Integer) getContext().get(PHASE);
141:            }
142:
143:            /**
144:             * @return <code>true</code> if the Portlet is executing in render phase.
145:             */
146:            public static boolean isRender() {
147:                return PortletActionConstants.RENDER_PHASE.equals(getPhase());
148:            }
149:
150:            /**
151:             * @return <code>true</code> if the Portlet is executing in the event phase.
152:             */
153:            public static boolean isEvent() {
154:                return PortletActionConstants.EVENT_PHASE.equals(getPhase());
155:            }
156:
157:            /**
158:             * @return The current ActionContext.
159:             */
160:            private static ActionContext getContext() {
161:                return ActionContext.getContext();
162:            }
163:
164:            /**
165:             * Check to see if the current request is a portlet request.
166:             *
167:             * @return <code>true</code> if the current request is a portlet request.
168:             */
169:            public static boolean isPortletRequest() {
170:                return getRequest() != null;
171:            }
172:
173:            /**
174:             * Get the default action mapping for the current mode.
175:             *
176:             * @return The default action mapping for the current portlet mode.
177:             */
178:            public static ActionMapping getDefaultActionForMode() {
179:                return (ActionMapping) getContext()
180:                        .get(DEFAULT_ACTION_FOR_MODE);
181:            }
182:
183:            /**
184:             * Get the namespace to mode mappings.
185:             *
186:             * @return The map of the namespaces for each mode.
187:             */
188:            public static Map getModeNamespaceMap() {
189:                return (Map) getContext().get(MODE_NAMESPACE_MAP);
190:            }
191:
192:            /**
193:             * Get the portlet context.
194:             * @return The portlet context.
195:             */
196:            public static PortletContext getPortletContext() {
197:                return (PortletContext) getContext().get(
198:                        StrutsStatics.STRUTS_PORTLET_CONTEXT);
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.