Source Code Cross Referenced for FormBuilderXml.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » site » 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 » rife 1.6.1 » com.uwyn.rife.site 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: FormBuilderXml.java 3697 2007-03-16 16:59:32Z gbevin $
007:         */
008:        package com.uwyn.rife.site;
009:
010:        import com.uwyn.rife.template.Template;
011:        import com.uwyn.rife.tools.ExceptionUtils;
012:        import com.uwyn.rife.tools.exceptions.BeanUtilsException;
013:        import java.util.ArrayList;
014:        import java.util.Collection;
015:        import java.util.Collections;
016:        import java.util.Map;
017:        import java.util.Set;
018:        import java.util.logging.Logger;
019:
020:        public class FormBuilderXml implements  FormBuilder {
021:            private ValidationBuilder mValidationBuilder = new ValidationBuilderXml();
022:
023:            public Collection<String> generateForm(Template template,
024:                    Class beanClass, Map<String, String[]> values, String prefix)
025:                    throws BeanUtilsException {
026:                if (null == beanClass) {
027:                    return Collections.EMPTY_LIST;
028:                }
029:
030:                // create an instance of the bean
031:                Object bean;
032:                try {
033:                    bean = beanClass.newInstance();
034:                } catch (Throwable e) {
035:                    bean = null;
036:                }
037:
038:                return _generateForm(template, bean, values, prefix);
039:            }
040:
041:            public Collection<String> generateForm(Template template,
042:                    Object bean, Map<String, String[]> values, String prefix)
043:                    throws BeanUtilsException {
044:                if (null == bean) {
045:                    return Collections.EMPTY_LIST;
046:                }
047:
048:                if (bean instanceof  Class)
049:                    throw new IllegalArgumentException(
050:                            "bean should be a bean instance, not a bean class.");
051:
052:                return _generateForm(template, bean, values, prefix);
053:            }
054:
055:            private Collection<String> _generateForm(Template template,
056:                    Object bean, Map<String, String[]> values, String prefix) {
057:                ArrayList<String> set_values = new ArrayList<String>();
058:
059:                if (null == template) {
060:                    return set_values;
061:                }
062:
063:                if (null == values && bean != null) {
064:                    // check if the bean is validated
065:                    Validated validated = null;
066:                    Set<ValidationError> previous_errors = null;
067:                    if (bean instanceof  Validated) {
068:                        validated = (Validated) bean;
069:
070:                        // check if validation errors are already present in the bean,
071:                        // and generate the formatted errors
072:                        set_values.addAll(mValidationBuilder
073:                                .generateValidationErrors(template, validated
074:                                        .getValidationErrors(), validated
075:                                        .getValidatedSubjects(), prefix));
076:                        set_values.addAll(mValidationBuilder
077:                                .generateErrorMarkings(template, validated
078:                                        .getValidationErrors(), validated
079:                                        .getValidatedSubjects(), prefix));
080:
081:                        // store the validation errors and revalidate
082:                        previous_errors = validated.getValidationErrors();
083:
084:                        // revalidate the bean to check which fields have to be displayed
085:                        validated.resetValidation();
086:                        validated.validate();
087:                    }
088:
089:                    if (validated != null) {
090:                        // restore the previous validation errors
091:                        validated.replaceValidationErrors(previous_errors);
092:                    }
093:                }
094:
095:                return set_values;
096:            }
097:
098:            public Collection<String> generateField(Template template,
099:                    ConstrainedProperty property, String[] values, String prefix) {
100:                return Collections.EMPTY_LIST;
101:            }
102:
103:            public Collection<String> generateField(Template template,
104:                    Class propertyType, ConstrainedProperty property,
105:                    String[] values, String prefix) {
106:                return Collections.EMPTY_LIST;
107:            }
108:
109:            public Collection<String> replaceField(Template template,
110:                    String templateFieldName, ConstrainedProperty property,
111:                    String[] values, String prefix) {
112:                return Collections.EMPTY_LIST;
113:            }
114:
115:            public Collection<String> replaceField(Template template,
116:                    String templateFieldName, Class propertyType,
117:                    ConstrainedProperty property, String[] values, String prefix) {
118:                return Collections.EMPTY_LIST;
119:            }
120:
121:            public Collection<String> generateField(Template template,
122:                    String name, String[] values, String prefix) {
123:                return Collections.EMPTY_LIST;
124:            }
125:
126:            public Collection<String> generateField(Template template,
127:                    Class propertyType, String name, String[] values,
128:                    String prefix) {
129:                return Collections.EMPTY_LIST;
130:            }
131:
132:            public Collection<String> replaceField(Template template,
133:                    String templateFieldName, String name, String[] values,
134:                    String prefix) {
135:                return Collections.EMPTY_LIST;
136:            }
137:
138:            public Collection<String> replaceField(Template template,
139:                    String templateFieldName, Class propertyType, String name,
140:                    String[] values, String prefix) {
141:                return Collections.EMPTY_LIST;
142:            }
143:
144:            public void removeForm(Template template, Class beanClass,
145:                    String prefix) throws BeanUtilsException {
146:                if (null == template || null == beanClass) {
147:                    return;
148:                }
149:
150:                // create an instance of the bean
151:                Object bean;
152:                try {
153:                    bean = beanClass.newInstance();
154:                } catch (Throwable e) {
155:                    bean = null;
156:                }
157:
158:                Validated validated;
159:                if (bean != null && bean instanceof  Validated) {
160:                    validated = (Validated) bean;
161:
162:                    mValidationBuilder.removeValidationErrors(template,
163:                            validated.getValidatedSubjects(), prefix);
164:                    mValidationBuilder.removeErrorMarkings(template, validated
165:                            .getValidatedSubjects(), prefix);
166:                }
167:            }
168:
169:            public void removeField(Template template, String name,
170:                    String prefix) {
171:            }
172:
173:            public void removeField(Template template, String templateFieldName) {
174:            }
175:
176:            public Collection<String> selectParameter(Template template,
177:                    String name, String[] values) {
178:                return Collections.EMPTY_LIST;
179:            }
180:
181:            public void unselectParameter(Template template, String name,
182:                    String[] values) {
183:            }
184:
185:            public ValidationBuilder getValidationBuilder() {
186:                return mValidationBuilder;
187:            }
188:
189:            public Object clone() {
190:                try {
191:                    FormBuilderXml other = (FormBuilderXml) super .clone();
192:
193:                    other.mValidationBuilder = (ValidationBuilder) this .mValidationBuilder
194:                            .clone();
195:
196:                    return other;
197:                } catch (CloneNotSupportedException e) {
198:                    ///CLOVER:OFF
199:                    // this should never happen
200:                    Logger.getLogger("com.uwyn.rife.site").severe(
201:                            ExceptionUtils.getExceptionStackTrace(e));
202:                    return null;
203:                    ///CLOVER:ON
204:                }
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.