Source Code Cross Referenced for AbstractValidateActionForm.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: AbstractValidateActionForm.java 481833 2006-12-03 17:32:52Z niallp $
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.commons.logging.Log;
024:        import org.apache.commons.logging.LogFactory;
025:        import org.apache.struts.action.ActionErrors;
026:        import org.apache.struts.action.ActionForm;
027:        import org.apache.struts.action.InvalidCancelException;
028:        import org.apache.struts.chain.contexts.ActionContext;
029:        import org.apache.struts.config.ActionConfig;
030:
031:        /**
032:         * <p>Validate the properties of the form bean for this request.  If there are
033:         * any validation errors, execute the specified command; otherwise, proceed
034:         * normally.</p>
035:         *
036:         * @version $Rev: 481833 $ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
037:         *          $
038:         */
039:        public abstract class AbstractValidateActionForm extends
040:                ActionCommandBase {
041:            // ------------------------------------------------------ Instance Variables
042:
043:            /**
044:             * <p> Provide Commons Logging instance for this class. </p>
045:             */
046:            private static final Log LOG = LogFactory
047:                    .getLog(AbstractSelectForward.class);
048:
049:            // ------------------------------------------------------ Protected Methods
050:
051:            /**
052:             * <p>Helper method to verify the Cancel state.</p>
053:             *
054:             * <p>If the state is invalid, Cancel is unset and an
055:             * InvalidCancelException is thrown.</p>
056:             *
057:             * @param actionCtx    Our ActionContext
058:             * @param actionConfig Our ActionConfig
059:             * @return true if cancel is set, false otherwise.
060:             * @throws InvalidCancelException
061:             */
062:            private boolean isCancelled(ActionContext actionCtx,
063:                    ActionConfig actionConfig) throws InvalidCancelException {
064:                Boolean cancel = actionCtx.getCancelled();
065:                boolean cancelled = ((cancel != null) && cancel.booleanValue());
066:                boolean cancellable = actionConfig.getCancellable();
067:
068:                boolean invalidState = (cancelled && !cancellable);
069:
070:                if (invalidState) {
071:                    actionCtx.setCancelled(Boolean.FALSE);
072:                    actionCtx.setFormValid(Boolean.FALSE);
073:                    throw new InvalidCancelException();
074:                }
075:
076:                return cancelled;
077:            }
078:
079:            // ---------------------------------------------------------- Public Methods
080:
081:            /**
082:             * <p>Validate the properties of the form bean for this request.  If there
083:             * are any validation errors, execute the child commands in our chain;
084:             * otherwise, proceed normally.</p>
085:             *
086:             * @param actionCtx The <code>Context</code> for the current request
087:             * @return <code>false</code> so that processing continues, if there are
088:             *         no validation errors; otherwise <code>true</code>
089:             * @throws Exception if thrown by the Action class
090:             */
091:            public boolean execute(ActionContext actionCtx) throws Exception {
092:                // Set form valid until found otherwise
093:                actionCtx.setFormValid(Boolean.TRUE);
094:
095:                // Is there a form bean for this request?
096:                ActionForm actionForm = actionCtx.getActionForm();
097:
098:                if (actionForm == null) {
099:                    return false;
100:                }
101:
102:                // Is validation disabled on this request?
103:                ActionConfig actionConfig = actionCtx.getActionConfig();
104:
105:                if (!actionConfig.getValidate()) {
106:                    return false;
107:                }
108:
109:                // Was this request cancelled?
110:                if (isCancelled(actionCtx, actionConfig)) {
111:                    if (LOG.isDebugEnabled()) {
112:                        LOG
113:                                .debug(" Cancelled transaction, skipping validation");
114:                    }
115:
116:                    return false;
117:                }
118:
119:                // Call the validate() method of this form bean
120:                ActionErrors errors = validate(actionCtx, actionConfig,
121:                        actionForm);
122:
123:                // If there were no errors, proceed normally
124:                if ((errors == null) || (errors.isEmpty())) {
125:                    return false;
126:                }
127:
128:                // Flag the validation failure and proceed
129:                /* NOTE: Is there any concern that there might have already
130:                 * been errors, or that other errors might be coming?
131:                 */
132:                actionCtx.saveErrors(errors);
133:                actionCtx.setFormValid(Boolean.FALSE);
134:
135:                return false;
136:            }
137:
138:            // ------------------------------------------------------- Protected Methods
139:
140:            /**
141:             * <p>Call the <code>validate()</code> method of the specified form bean,
142:             * and return the resulting <code>ActionErrors</code> object.</p>
143:             *
144:             * @param context      The context for this request
145:             * @param actionConfig The <code>ActionConfig</code> for this request
146:             * @param actionForm   The form bean for this request
147:             * @return ActionErrors object, if any
148:             */
149:            protected abstract ActionErrors validate(ActionContext context,
150:                    ActionConfig actionConfig, ActionForm actionForm);
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.