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


001:        package com.opensymphony.webwork.dispatcher;
002:
003:        import java.util.Arrays;
004:        import java.util.HashMap;
005:        import java.util.Iterator;
006:        import java.util.List;
007:        import java.util.Map;
008:
009:        import com.opensymphony.webwork.dispatcher.mapper.ActionMapper;
010:        import com.opensymphony.webwork.dispatcher.mapper.ActionMapperFactory;
011:        import com.opensymphony.webwork.dispatcher.mapper.ActionMapping;
012:        import com.opensymphony.webwork.views.util.UrlHelper;
013:
014:        import com.opensymphony.xwork.ActionInvocation;
015:        import com.opensymphony.xwork.config.entities.ActionConfig;
016:        import com.opensymphony.xwork.config.entities.ResultConfig;
017:
018:        /**
019:         * <!-- START SNIPPET: description -->
020:         *
021:         * This result uses the {@link ActionMapper} provided by the {@link ActionMapperFactory} to redirect the browser to a
022:         * URL that invokes the specified action and (optional) namespace. This is better than the {@link ServletRedirectResult}
023:         * because it does not require you to encode the URL patterns processed by the {@link ActionMapper} in to your xwork.xml
024:         * configuration files. This means you can change your URL patterns at any point and your application will still work.
025:         * It is strongly recommended that if you are redirecting to another action, you use this result rather than the
026:         * standard redirect result.
027:         * 
028:         * <p/>
029:         * 
030:         * To pass parameters, the &lt;param&gt; ... &lt;/param&gt; tag. The following parameters will not be 
031:         * passable becuase they are part of the config param for this particular result.
032:         * 
033:         * <ul>
034:         * 	<li>actionName</li>
035:         *  <li>namespace</li>
036:         *  <li>method</li>
037:         *  <li>encode</li>
038:         *  <li>parse</li>
039:         *  <li>location</li>
040:         *  <li>prependServletContext</li>
041:         * </ul>
042:         * 
043:         * See examples below for an example of how request parameters could be passed in.
044:         *
045:         * <!-- END SNIPPET: description -->
046:         *
047:         * <b>This result type takes the following parameters:</b>
048:         *
049:         * <!-- START SNIPPET: params -->
050:         *
051:         * <ul>
052:         *
053:         * <li><b>actionName (default)</b> - the name of the action that will be redirect to</li>
054:         *
055:         * <li><b>namespace</b> - used to determine which namespace the action is in that we're redirecting to . If namespace is
056:         * null, this defaults to the current namespace</li>
057:         *
058:         * </ul>
059:         *
060:         * <!-- END SNIPPET: params -->
061:         *
062:         * <b>Example:</b>
063:         *
064:         * <pre><!-- START SNIPPET: example -->
065:         * &lt;package name="public" extends="webwork-default"&gt;
066:         *     &lt;action name="login" class="..."&gt;
067:         *         &lt;!-- Redirect to another namespace --&gt;
068:         *         &lt;result type="redirect-action"&gt;
069:         *             &lt;param name="actionName"&gt;dashboard&lt;/param&gt;
070:         *             &lt;param name="namespace"&gt;/secure&lt;/param&gt;
071:         *         &lt;/result&gt;
072:         *     &lt;/action&gt;
073:         * &lt;/package&gt;
074:         *
075:         * &lt;package name="secure" extends="webwork-default" namespace="/secure"&gt;
076:         *     &lt;-- Redirect to an action in the same namespace --&gt;
077:         *     &lt;action name="dashboard" class="..."&gt;
078:         *         &lt;result&gt;dashboard.jsp&lt;/result&gt;
079:         *         &lt;result name="error" type="redirect-action&gt;error&lt;/result&gt;
080:         *     &lt;/action&gt;
081:         *
082:         *     &lt;action name="error" class="..."&gt;
083:         *         &lt;result&gt;error.jsp&lt;/result&gt;
084:         *     &lt;/action&gt;
085:         * &lt;/package&gt;
086:         * 
087:         * &lt;package name="passingRequestParameters" extends="webwork-default" namespace="/passingRequestParameters"&gt;
088:         * 	  &lt;-- Pass parameters (reportType, width and height) --&gt;
089:         *    &lt;!-- 
090:         *    The redirect-action url generated will be : 
091:         *    /genReport/generateReport.action?reportType=pie&width=100&height=100
092:         *    --&gt;
093:         *    &lt;action name="gatherReportInfo" class="..."&gt;
094:         *       &lt;result name="showReportResult" type="redirect-action"&gt;
095:         *       	&lt;param name="actionName"&gt;generateReport&lt;/param&gt;
096:         *          &lt;param name="namespace="&gt;/genReport&lt;/param&gt;
097:         *          &lt;param name="reportType"&gt;pie&lt;/param&gt;
098:         *          &lt;param name="width"&gt;100&lt;/param&gt;
099:         *          &lt;param name="height"&gt;100&lt;/param&gt;
100:         *       &lt;/result&gt;
101:         *    &lt;/action&gt;
102:         * &lt;/package&gt;
103:         * 
104:         * <!-- END SNIPPET: example --></pre>
105:         *
106:         * @see ActionMapper
107:         */
108:        public class ServletActionRedirectResult extends ServletRedirectResult {
109:
110:            private static final long serialVersionUID = -6126889518132056284L;
111:
112:            public static final String DEFAULT_PARAM = "actionName";
113:
114:            protected String actionName;
115:            protected String namespace;
116:            protected String method;
117:
118:            protected List prohibitedResultParam = Arrays.asList(new String[] {
119:                    DEFAULT_PARAM, "namespace", "method", "encode", "parse",
120:                    "location", "prependServletContext" });
121:
122:            public void execute(ActionInvocation invocation) throws Exception {
123:                actionName = conditionalParse(actionName, invocation);
124:                if (namespace == null) {
125:                    namespace = invocation.getProxy().getNamespace();
126:                } else {
127:                    namespace = conditionalParse(namespace, invocation);
128:                }
129:                if (method == null) {
130:                    method = "";
131:                } else {
132:                    method = conditionalParse(method, invocation);
133:                }
134:
135:                Map requestParameters = new HashMap();
136:                ResultConfig resultConfig = (ResultConfig) invocation
137:                        .getProxy().getConfig().getResults().get(
138:                                invocation.getResultCode());
139:                Map resultConfigParams = resultConfig.getParams();
140:                for (Iterator i = resultConfigParams.entrySet().iterator(); i
141:                        .hasNext();) {
142:                    Map.Entry e = (Map.Entry) i.next();
143:                    if (!prohibitedResultParam.contains(e.getKey())) {
144:                        requestParameters.put(e.getKey().toString(), e
145:                                .getValue() == null ? "" : conditionalParse(e
146:                                .getValue().toString(), invocation));
147:                    }
148:                }
149:
150:                ActionMapper mapper = ActionMapperFactory.getMapper();
151:                StringBuffer tmpLocation = new StringBuffer(mapper
152:                        .getUriFromActionMapping(new ActionMapping(actionName,
153:                                namespace, method, null)));
154:                UrlHelper.buildParametersString(requestParameters, tmpLocation,
155:                        "&");
156:
157:                location = tmpLocation.toString();
158:
159:                super .execute(invocation);
160:            }
161:
162:            public void setActionName(String actionName) {
163:                this .actionName = actionName;
164:            }
165:
166:            public void setNamespace(String namespace) {
167:                this .namespace = namespace;
168:            }
169:
170:            public void setMethod(String method) {
171:                this.method = method;
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.