Source Code Cross Referenced for BaseFieldConstraint.java in  » Web-Framework » aranea-mvc-1.1.1 » org » araneaframework » uilib » form » constraint » 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 » aranea mvc 1.1.1 » org.araneaframework.uilib.form.constraint 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2006 Webmedia Group Ltd.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *  http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         **/package org.araneaframework.uilib.form.constraint;
016:
017:        import org.araneaframework.Environment;
018:        import org.araneaframework.core.AraneaRuntimeException;
019:        import org.araneaframework.core.Assert;
020:        import org.araneaframework.core.NoSuchEnvironmentEntryException;
021:        import org.araneaframework.uilib.form.FormElement;
022:        import org.araneaframework.uilib.form.FormElementContext;
023:
024:        /**
025:         * {@link org.araneaframework.uilib.form.Constraint} that is associated with
026:         * some {@link org.araneaframework.uilib.form.FormElement}.
027:         * 
028:         * @author Taimo Peelo (taimo@araneaframework.org)
029:         */
030:        public abstract class BaseFieldConstraint extends BaseConstraint {
031:            private FormElement field;
032:
033:            public BaseFieldConstraint() {
034:            }
035:
036:            // Constraints environment should always be set to field environment.
037:            // however there is no guarantee that field has been initialized when
038:            // constructor is called, so the environment may be missing crucial entries.
039:            // Just setting field constraint works (then constraints environment is set when 
040:            // field is initialized). That would break constraint previously set however.
041:            public BaseFieldConstraint(FormElement field) {
042:                Assert.notNullParam(this , field, "field");
043:                this .field = field;
044:            }
045:
046:            /**
047:             * Returns the {@link FormElement} that 
048:             * this {@link org.araneaframework.uilib.form.Constraint} is constraining.
049:             * 
050:             * @return constrained {@link FormElement}
051:             */
052:            protected FormElementContext getField() {
053:                if (field != null)
054:                    return field;
055:
056:                FormElementContext result;
057:                try {
058:                    result = (FormElementContext) getEnvironment()
059:                            .requireEntry(FormElementContext.class);
060:                } catch (NoSuchEnvironmentEntryException e) {
061:                    throw new FieldConstraintException(
062:                            Assert.this ToString(this )
063:                                    + " could not determine FormElementContext, this is probably caused by applying field constraint to something other than FormElement.",
064:                            e);
065:                }
066:                return result;
067:            }
068:
069:            public Environment getEnvironment() {
070:                if (field == null)
071:                    return super .getEnvironment();
072:                return field.getConstraintEnvironment();
073:            }
074:
075:            protected String getLabel() {
076:                return getField().getLabel();
077:            }
078:
079:            protected Object getValue() {
080:                return getField().getValue();
081:            }
082:
083:            public boolean isRead() {
084:                return getField().isRead();
085:            }
086:
087:            public boolean isDisabled() {
088:                return getField().isDisabled();
089:            }
090:
091:            public boolean isMandatory() {
092:                return getField().isMandatory();
093:            }
094:
095:            /**
096:             * Exception thrown when {@link org.araneaframework.uilib.form.FormElement} associated with 
097:             * {@link BaseFieldConstraint} could not be determined.
098:             */
099:            public static class FieldConstraintException extends
100:                    AraneaRuntimeException {
101:                public FieldConstraintException() {
102:                    super ();
103:                }
104:
105:                public FieldConstraintException(String message, Throwable cause) {
106:                    super (message, cause);
107:                }
108:
109:                public FieldConstraintException(String message) {
110:                    super (message);
111:                }
112:
113:                public FieldConstraintException(Throwable cause) {
114:                    super(cause);
115:                }
116:            }
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.