Source Code Cross Referenced for AbstractPopulateActionForm.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » chain » commands » 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 1.3.8 » org.apache.struts.chain.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AbstractPopulateActionForm.java 471754 2006-11-06 14:55:09Z husted $
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.struts.chain.commands;
022:
023:        import org.apache.struts.Globals;
024:        import org.apache.struts.action.ActionForm;
025:        import org.apache.struts.chain.contexts.ActionContext;
026:        import org.apache.struts.config.ActionConfig;
027:
028:        import java.util.Map;
029:
030:        /**
031:         * <p>Populate the form bean (if any) for this request.</p>
032:         *
033:         * @version $Rev: 471754 $ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
034:         *          $
035:         */
036:        public abstract class AbstractPopulateActionForm extends
037:                ActionCommandBase {
038:            // ---------------------------------------------------------- Public Methods
039:
040:            /**
041:             * <p>Populate the form bean (if any) for this request.</p>
042:             *
043:             * @param actionCtx The <code>Context</code> for the current request
044:             * @return <code>false</code> so that processing continues
045:             * @throws Exception On an unexpected error
046:             */
047:            public boolean execute(ActionContext actionCtx) throws Exception {
048:                // Is there a form bean for this request?
049:                ActionForm actionForm = actionCtx.getActionForm();
050:
051:                if (actionForm == null) {
052:                    return (false);
053:                }
054:
055:                // Reset the form bean property values
056:                ActionConfig actionConfig = actionCtx.getActionConfig();
057:
058:                reset(actionCtx, actionConfig, actionForm);
059:
060:                populate(actionCtx, actionConfig, actionForm);
061:
062:                handleCancel(actionCtx, actionConfig, actionForm);
063:
064:                return (false);
065:            }
066:
067:            // ------------------------------------------------------- Protected Methods
068:
069:            /**
070:             * <p>Call the <code>reset()</code> method on the specified form
071:             * bean.</p>
072:             *
073:             * @param context      The context for this request
074:             * @param actionConfig The actionConfig for this request
075:             * @param actionForm   The form bean for this request
076:             */
077:            protected abstract void reset(ActionContext context,
078:                    ActionConfig actionConfig, ActionForm actionForm);
079:
080:            /**
081:             * <p> Populate the given <code>ActionForm</code> with request parameter
082:             * values, taking into account any prefix/suffix values configured on the
083:             * given <code>ActionConfig</code>. </p>
084:             *
085:             * @param context      The ActionContext we are processing
086:             * @param actionConfig The ActionConfig we are processing
087:             * @param actionForm   The ActionForm we are processing
088:             * @throws Exception On an unexpected error
089:             */
090:            protected abstract void populate(ActionContext context,
091:                    ActionConfig actionConfig, ActionForm actionForm)
092:                    throws Exception;
093:
094:            // original implementation casting context to WebContext is not safe
095:            // when the input value is an ActionContext.
096:
097:            /**
098:             * <p>For a given request parameter name, trim off any prefix and/or
099:             * suffix which are defined in <code>actionConfig</code> and return what
100:             * remains. If either prefix or suffix is defined, then return null for
101:             * <code>name</code> values which do not begin or end accordingly.</p>
102:             *
103:             * @param actionConfig The ActionConfig we are processing
104:             * @param name         The request parameter name to proceess
105:             * @return The request parameter name trimmed of any suffix or prefix
106:             */
107:            protected String trimParameterName(ActionConfig actionConfig,
108:                    String name) {
109:                String stripped = name;
110:                String prefix = actionConfig.getPrefix();
111:                String suffix = actionConfig.getSuffix();
112:
113:                if (prefix != null) {
114:                    if (!stripped.startsWith(prefix)) {
115:                        return null;
116:                    }
117:
118:                    stripped = stripped.substring(prefix.length());
119:                }
120:
121:                if (suffix != null) {
122:                    if (!stripped.endsWith(suffix)) {
123:                        return null;
124:                    }
125:
126:                    stripped = stripped.substring(0, stripped.length()
127:                            - suffix.length());
128:                }
129:
130:                return stripped;
131:            }
132:
133:            /**
134:             * <p>Take into account whether the request includes any defined value for
135:             * the global "cancel" parameter.</p> <p> An issue was raised (but I don't
136:             * think a Bugzilla ticket created) about the security implications of
137:             * using a well-known cancel property which skips form validation, as you
138:             * may not write your actions to deal with the cancellation case. </p>
139:             *
140:             * @param context      The ActionContext we are processing
141:             * @param actionConfig The ActionConfig we are processing
142:             * @param actionForm   The ActionForm we are processing
143:             * @throws Exception On an unexpected error
144:             * @see Globals.CANCEL_PROPERTY
145:             * @see Globals.CANCEL_PROPERTY_X
146:             */
147:            protected void handleCancel(ActionContext context,
148:                    ActionConfig actionConfig, ActionForm actionForm)
149:                    throws Exception {
150:                Map paramValues = context.getParameterMap();
151:
152:                // Set the cancellation attribute if appropriate
153:                if ((paramValues.get(Globals.CANCEL_PROPERTY) != null)
154:                        || (paramValues.get(Globals.CANCEL_PROPERTY_X) != null)) {
155:                    context.setCancelled(Boolean.TRUE);
156:                } else {
157:                    context.setCancelled(Boolean.FALSE);
158:                }
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.