Source Code Cross Referenced for FormLoader.java in  » Database-Client » dbmjui » fr » aliacom » form » common » 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 » Database Client » dbmjui » fr.aliacom.form.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package fr.aliacom.form.common;
002:
003:        import java.util.ArrayList;
004:        import java.util.HashMap;
005:        import java.util.Iterator;
006:
007:        import org.apache.log4j.Logger;
008:
009:        /**
010:         * This class is responsible of iterating an <code>ILoader</code> list and use
011:         * them to push the variable from the <code>FormContext</code> to the form UI.
012:         * 
013:         * Given a FormContext A and an IForm B, it is legal to have 
014:         * <code>B.getFormContext() != A.getForm()</code>.
015:         * 
016:         * You can add multiple <code>ILoader</code> instances for a single form
017:         * variable. It is usefull when several form components displaying the same
018:         * variable.
019:         * 
020:         * @author tom
021:         *
022:         *  (C) 2001, 2003 Thomas Cataldo
023:         */
024:        public final class FormLoader {
025:
026:            private HashMap loaderMap;
027:            private IForm form;
028:            private FormContext ctx;
029:            private static final Logger log = Logger
030:                    .getLogger(FormLoader.class);
031:
032:            /**
033:             * Creates a form loader with the given form reference.
034:             * @param f the form loaded by the current loader instance
035:             */
036:            public FormLoader(IForm f) {
037:                this .form = f;
038:                if (f != null) {
039:                    this .ctx = f.getFormContext();
040:                }
041:                loaderMap = new HashMap();
042:            }
043:
044:            /**
045:             * Creates a form context with a null form reference.
046:             */
047:            public FormLoader() {
048:                this ((IForm) null);
049:            }
050:
051:            /**
052:             * Creates a form loader with a null form reference and the givent context.
053:             * @param ctx
054:             */
055:            public FormLoader(FormContext ctx) {
056:                this ((IForm) null);
057:                this .ctx = ctx;
058:            }
059:
060:            public FormContext getCtx() {
061:                return ctx;
062:            }
063:
064:            /**
065:             * Add an ILoader used to load a specific FormVariable
066:             * 
067:             * @param formVariable the name of the variable you want to add a loader to.
068:             * @param loader the loader used to load the FormVariable
069:             */
070:            public void addLoader(String formVariable, ILoader loader) {
071:                ArrayList al = (ArrayList) loaderMap.get(formVariable);
072:                if (al == null) {
073:                    al = new ArrayList(1);
074:                    loaderMap.put(formVariable, al);
075:                }
076:
077:                al.add(loader);
078:            }
079:
080:            public void load() {
081:                Iterator it = getCtx().getVariables();
082:                while (it.hasNext()) {
083:                    FormVariable var = (FormVariable) it.next();
084:                    log.debug("Loading variable '" + var.getName() + "'");
085:                    load(var.getName());
086:                }
087:            }
088:
089:            private void load(String formVariable) {
090:                directLoad(formVariable, getCtx().get(formVariable).getValue());
091:            }
092:
093:            private void directLoad(String property, Object value) {
094:                ArrayList v = (ArrayList) loaderMap.get(property);
095:                if (v != null) {
096:                    int size = v.size();
097:                    for (int i = 0; i < size; i++) {
098:                        ((ILoader) v.get(i)).load(value);
099:                    }
100:                }
101:            }
102:
103:            /**
104:             * Changes the form this loader will load
105:             * 
106:             * @param form the form that will be loaded
107:             */
108:            public void setForm(IForm form) {
109:                this .form = form;
110:            }
111:
112:            /**
113:             * Returns the form loaded by this loader.
114:             * @return the form loaded by this loader.
115:             */
116:            public IForm getForm() {
117:                return form;
118:            }
119:
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.