Source Code Cross Referenced for PortletActionContext.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.portlet.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2006 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.portlet.context;
006:
007:        import java.util.Map;
008:
009:        import javax.portlet.ActionRequest;
010:        import javax.portlet.ActionResponse;
011:        import javax.portlet.PortletConfig;
012:        import javax.portlet.PortletRequest;
013:        import javax.portlet.PortletResponse;
014:        import javax.portlet.RenderRequest;
015:        import javax.portlet.RenderResponse;
016:
017:        import com.opensymphony.webwork.portlet.PortletActionConstants;
018:        import com.opensymphony.xwork.ActionContext;
019:
020:        /**
021:         * PortletActionContext. ActionContext thread local for the portlet environment.
022:         * 
023:         * @author Nils-Helge Garli
024:         * @version $Revision: 2338 $ $Date: 2006-03-08 21:22:35 +0100 (Wed, 08 Mar 2006) $
025:         */
026:        public class PortletActionContext implements  PortletActionConstants {
027:
028:            /**
029:             * Get the PortletConfig of the portlet that is executing.
030:             *
031:             * @return The PortletConfig of the executing portlet.
032:             */
033:            public static PortletConfig getPortletConfig() {
034:                return (PortletConfig) getContext().get(PORTLET_CONFIG);
035:            }
036:
037:            /**
038:             * Get the RenderRequest. Can only be invoked in the render phase.
039:             *
040:             * @return The current RenderRequest.
041:             * @throws IllegalStateException If the method is invoked in the wrong phase.
042:             */
043:            public static RenderRequest getRenderRequest() {
044:                if (!isRender()) {
045:                    throw new IllegalStateException(
046:                            "RenderRequest cannot be obtained in event phase");
047:                }
048:                return (RenderRequest) getContext().get(REQUEST);
049:            }
050:
051:            /**
052:             * Get the RenderResponse. Can only be invoked in the render phase.
053:             *
054:             * @return The current RenderResponse.
055:             * @throws IllegalStateException If the method is invoked in the wrong phase.
056:             */
057:            public static RenderResponse getRenderResponse() {
058:                if (!isRender()) {
059:                    throw new IllegalStateException(
060:                            "RenderResponse cannot be obtained in event phase");
061:                }
062:                return (RenderResponse) getContext().get(RESPONSE);
063:            }
064:
065:            /**
066:             * Get the ActionRequest. Can only be invoked in the event phase.
067:             *
068:             * @return The current ActionRequest.
069:             * @throws IllegalStateException If the method is invoked in the wrong phase.
070:             */
071:            public static ActionRequest getActionRequest() {
072:                if (!isEvent()) {
073:                    throw new IllegalStateException(
074:                            "ActionRequest cannot be obtained in render phase");
075:                }
076:                return (ActionRequest) getContext().get(REQUEST);
077:            }
078:
079:            /**
080:             * Get the ActionRequest. Can only be invoked in the event phase.
081:             *
082:             * @return The current ActionRequest.
083:             * @throws IllegalStateException If the method is invoked in the wrong phase.
084:             */
085:            public static ActionResponse getActionResponse() {
086:                if (!isEvent()) {
087:                    throw new IllegalStateException(
088:                            "ActionResponse cannot be obtained in render phase");
089:                }
090:                return (ActionResponse) getContext().get(RESPONSE);
091:            }
092:
093:            /**
094:             * Get the action namespace of the portlet. Used to organize actions for multiple portlets in
095:             * the same portlet application.
096:             *
097:             * @return The portlet namespace as defined in <code>portlet.xml</code> and <code>xwork.xml</code>
098:             */
099:            public static String getPortletNamespace() {
100:                return (String) getContext().get(PORTLET_NAMESPACE);
101:            }
102:
103:            /**
104:             * Get the current PortletRequest.
105:             *
106:             * @return The current PortletRequest.
107:             */
108:            public static PortletRequest getRequest() {
109:                return (PortletRequest) getContext().get(REQUEST);
110:            }
111:
112:            /**
113:             * Get the current PortletResponse
114:             *
115:             * @return The current PortletResponse.
116:             */
117:            public static PortletResponse getResponse() {
118:                return (PortletResponse) getContext().get(RESPONSE);
119:            }
120:
121:            /**
122:             * Get the phase that the portlet is executing in.
123:             *
124:             * @return {@link PortletActionConstants#RENDER_PHASE} in render phase, and
125:             * {@link PortletActionConstants#EVENT_PHASE} in the event phase.
126:             */
127:            public static Integer getPhase() {
128:                return (Integer) getContext().get(PHASE);
129:            }
130:
131:            /**
132:             * @return <code>true</code> if the Portlet is executing in render phase.
133:             */
134:            public static boolean isRender() {
135:                return PortletActionConstants.RENDER_PHASE.equals(getPhase());
136:            }
137:
138:            /**
139:             * @return <code>true</code> if the Portlet is executing in the event phase.
140:             */
141:            public static boolean isEvent() {
142:                return PortletActionConstants.EVENT_PHASE.equals(getPhase());
143:            }
144:
145:            /**
146:             * @return The current ActionContext.
147:             */
148:            private static ActionContext getContext() {
149:                return ActionContext.getContext();
150:            }
151:
152:            /**
153:             * Check to see if the current request is a portlet request.
154:             *
155:             * @return <code>true</code> if the current request is a portlet request.
156:             */
157:            public static boolean isPortletRequest() {
158:                return getRequest() != null;
159:            }
160:
161:            /**
162:             * Get the default action name for the current mode.
163:             *
164:             * @return The default action name for the current portlet mode.
165:             */
166:            public static String getDefaultActionForMode() {
167:                return (String) getContext().get(DEFAULT_ACTION_FOR_MODE);
168:            }
169:
170:            /**
171:             * Get the namespace to mode mappings.
172:             * 
173:             * @return The map of the namespaces for each mode.
174:             */
175:            public static Map getModeNamespaceMap() {
176:                return (Map) getContext().get(MODE_NAMESPACE_MAP);
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.