Source Code Cross Referenced for FlashInterceptor.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » interceptor » 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.interceptor 
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.interceptor;
006:
007:        import java.util.Map;
008:
009:        import org.apache.commons.logging.Log;
010:        import org.apache.commons.logging.LogFactory;
011:
012:        import com.opensymphony.webwork.dispatcher.FlashResult;
013:        import com.opensymphony.xwork.ActionContext;
014:        import com.opensymphony.xwork.ActionInvocation;
015:        import com.opensymphony.xwork.interceptor.AroundInterceptor;
016:        import com.opensymphony.xwork.interceptor.PreResultListener;
017:        import com.opensymphony.xwork.util.OgnlValueStack;
018:
019:        /**
020:         * <!-- START SNIPPET: description -->
021:         * Flash interceptor ({@link FlashInterceptor}) possibly with {@link FlashResult} 
022:         * allows current action to be available even after a redirect. It does this by 
023:         * saving the current action into http session and pushing it back into the stack
024:         * next request, resulting in the nett effect of the action and its related information
025:         * being available across redirect.
026:         * <!-- END SNIPPET: description -->
027:         * 
028:         * 
029:         * <!-- START SNIPPET: parameters -->
030:         * <ul>
031:         * 	<li>key - The Http Session key under which the action will be stored, 
032:         *                     default to {@link FlashInterceptor#DEFAULT_KEY} which is 
033:         *                     the string '__flashAction'.</li>
034:         *     <li>operation - The operation mode of this interceptor, either 
035:         *     				{@link FlashInterceptor#STORE} having a string value of 'Store' or
036:         *     				{@link FlashInterceptor#RETRIEVE} having a string value of 'Retrieve'
037:         *     				The default operation mode is {@link FlashInterceptor#RETRIEVE}</li>
038:         * </ul>
039:         * <!-- END SNIPPET: parameters -->
040:         * 
041:         * 
042:         * <!-- START SNIPPET: extending -->
043:         * There's no intended extension points
044:         * <!-- END SNIPPET: extending -->
045:         * 
046:         * 
047:         * <pre>
048:         * <!-- START SNIPPET: example -->
049:         * &lt;!-- Usage 1: (Using only Flash interceptor)  --&gt;
050:         * &lt;action name="store" ...&gt;
051:         * 	&lt;interceptor-ref name="flash"&gt;
052:         * 		&lt;param name="operation"&gt;Store&lt;/param&gt;
053:         *     &lt;/interceptor-ref&gt;
054:         *     &lt;interceptor-ref name="defaultStack" /&gt;
055:         *     &lt;result type="redirect"&gt;redirectToSomeWhere.jsp&lt;/result&gt;
056:         * &lt;/action&gt;
057:         * &lt;action name="retrieve"&gt;
058:         * 	&lt;interceptor-ref name="flash"&gt;
059:         *        &lt;param name="operation"&gt;Retrieve&lt;/param&gt;
060:         *     &lt;/interceptor-ref&gt;
061:         *     &lt;interceptor-ref name="defaultStack" /&gt;
062:         *     &lt;result&gt;pageWhereWeNeedFlashActionStored.jsp&lt;/result&gt;
063:         * &lt;/action&gt;
064:         * 
065:         * 
066:         * &lt;!-- Usage 2: (Using Flash Interceptor and Flash Result) --&gt;
067:         * &lt;action name="store"&gt;
068:         * 	&lt;result type="flash"&gt;redirectToSomeWhere.jsp&lt;/result&gt;
069:         * &lt;/action&gt;
070:         * &lt;action name="retrieve"&gt;
071:         * 	&lt;interceptor-ref name="flash"&gt;
072:         *        &lt;param name="operation"&gt;Retrieve&lt;/param&gt;
073:         *     &lt;/interceptor-ref&gt;
074:         *     &lt;interceptor-ref name="defaultStack" /&gt;
075:         *     &lt;result&gt;pageWhereWeNeedFlashActionStored.jsp&lt;/result&gt;
076:         * &lt;/action&gt;
077:         * 
078:         * <!-- END SNIPPET: example -->
079:         * </pre>
080:         * 
081:         * 
082:         * @author tmjee
083:         * @version $Date: 2007-02-04 06:33:20 +0100 (Sun, 04 Feb 2007) $ $Id: FlashInterceptor.java 2830 2007-02-04 05:33:20Z tm_jee $
084:         */
085:        public class FlashInterceptor extends AroundInterceptor {
086:
087:            public static final String DEFAULT_KEY = "__flashAction";
088:            public static final String STORE = "Store";
089:            public static final String RETRIEVE = "Retrieve";
090:
091:            private static final Log LOG = LogFactory
092:                    .getLog(FlashInterceptor.class);
093:
094:            private static final long serialVersionUID = -9200319895107209641L;
095:
096:            private String key = DEFAULT_KEY;
097:            private String operation = RETRIEVE;
098:
099:            public void setKey(String key) {
100:                this .key = key;
101:            }
102:
103:            public String getKey() {
104:                return this .key;
105:            }
106:
107:            public void setOperation(String operation) {
108:                this .operation = operation;
109:            }
110:
111:            public String getOperation() {
112:                return this .operation;
113:            }
114:
115:            /**
116:             * @see com.opensymphony.xwork.interceptor.AroundInterceptor#after(com.opensymphony.xwork.ActionInvocation, java.lang.String)
117:             */
118:            protected void after(ActionInvocation invocation, String result)
119:                    throws Exception {
120:            }
121:
122:            /**
123:             * @see com.opensymphony.xwork.interceptor.AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation)
124:             */
125:            protected void before(ActionInvocation invocation) throws Exception {
126:                Map sessionMap = ActionContext.getContext().getSession();
127:
128:                if (STORE.equalsIgnoreCase(operation)) {
129:                    invocation.addPreResultListener(new PreResultListener() {
130:                        public void beforeResult(ActionInvocation invocation,
131:                                String resultCode) {
132:                            Map sessionMap = ActionContext.getContext()
133:                                    .getSession();
134:                            Object action = invocation.getAction();
135:                            if (LOG.isDebugEnabled())
136:                                LOG.debug("inserting action [" + action
137:                                        + "] into session with key [" + key
138:                                        + "]");
139:                            sessionMap.put(key, action);
140:                        }
141:                    });
142:                }
143:
144:                if (RETRIEVE.equalsIgnoreCase(operation)) {
145:                    if (sessionMap.get(key) != null) {
146:                        Object action = sessionMap.get(key);
147:                        if (LOG.isDebugEnabled()) {
148:                            LOG.debug("flash action with key [" + key
149:                                    + "] found in session, pushed action ["
150:                                    + action + "] into stack");
151:                        }
152:                        OgnlValueStack stack = (OgnlValueStack) ActionContext
153:                                .getContext().get(ActionContext.VALUE_STACK);
154:                        stack.push(action);
155:                        sessionMap.remove(key);
156:                        if (LOG.isDebugEnabled()) {
157:                            LOG
158:                                    .debug("flash action with key ["
159:                                            + key
160:                                            + "] with actual type ["
161:                                            + action
162:                                            + "] removed from session after being pushed into the stack ");
163:                        }
164:                    } else {
165:                        if (LOG.isDebugEnabled()) {
166:                            LOG
167:                                    .debug("flash action key ["
168:                                            + key
169:                                            + "] not found in session, no action is pushed into stack");
170:                        }
171:                    }
172:                }
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.